//@ sourceMappingURL=UI.map
/*******************************************************************************
 * Misc.
 */

// Workaround for missing functionality in IE 8 and earlier.
if( Object.create === undefined ) {
  Object.create = function( o ) {
    function F(){}
    F.prototype = o;
    return new F();
  };
}

// Insert properties of b in place into a.
function Fay$$objConcat(a,b){
  for (var p in b) if (b.hasOwnProperty(p)){
    a[p] = b[p];
  }
  return a;
}

/*******************************************************************************
 * Thunks.
 */

// Force a thunk (if it is a thunk) until WHNF.
function Fay$$_(thunkish,nocache){
  while (thunkish instanceof Fay$$$) {
    thunkish = thunkish.force(nocache);
  }
  return thunkish;
}

// Apply a function to arguments (see method2 in Fay.hs).
function Fay$$__(){
  var f = arguments[0];
  for (var i = 1, len = arguments.length; i < len; i++) {
    f = (f instanceof Fay$$$? Fay$$_(f) : f)(arguments[i]);
  }
  return f;
}

// Thunk object.
function Fay$$$(value){
  this.forced = false;
  this.value = value;
}

// Force the thunk.
Fay$$$.prototype.force = function(nocache) {
  return nocache ?
    this.value() :
    (this.forced ?
     this.value :
     (this.value = this.value(), this.forced = true, this.value));
};


function Fay$$seq(x) {
  return function(y) {
    Fay$$_(x,false);
    return y;
  }
}

function Fay$$seq$36$uncurried(x,y) {
  Fay$$_(x,false);
  return y;
}

/*******************************************************************************
 * Monad.
 */

function Fay$$Monad(value){
  this.value = value;
}

// This is used directly from Fay, but can be rebound or shadowed. See primOps in Types.hs.
// >>
function Fay$$then(a){
  return function(b){
    return Fay$$bind(a)(function(_){
      return b;
    });
  };
}

// This is used directly from Fay, but can be rebound or shadowed. See primOps in Types.hs.
// >>
function Fay$$then$36$uncurried(a,b){
  return Fay$$bind$36$uncurried(a,function(_){ return b; });
}

// >>=
// This is used directly from Fay, but can be rebound or shadowed. See primOps in Types.hs.
function Fay$$bind(m){
  return function(f){
    return new Fay$$$(function(){
      var monad = Fay$$_(m,true);
      return Fay$$_(f)(monad.value);
    });
  };
}

// >>=
// This is used directly from Fay, but can be rebound or shadowed. See primOps in Types.hs.
function Fay$$bind$36$uncurried(m,f){
  return new Fay$$$(function(){
    var monad = Fay$$_(m,true);
    return Fay$$_(f)(monad.value);
  });
}

// This is used directly from Fay, but can be rebound or shadowed.
function Fay$$$_return(a){
  return new Fay$$Monad(a);
}

// Allow the programmer to access thunk forcing directly.
function Fay$$force(thunk){
  return function(type){
    return new Fay$$$(function(){
      Fay$$_(thunk,type);
      return new Fay$$Monad(Fay$$unit);
    })
  }
}

// This is used directly from Fay, but can be rebound or shadowed.
function Fay$$return$36$uncurried(a){
  return new Fay$$Monad(a);
}

// Unit: ().
var Fay$$unit = null;

/*******************************************************************************
 * Serialization.
 * Fay <-> JS. Should be bijective.
 */

// Serialize a Fay object to JS.
function Fay$$fayToJs(type,fayObj){
  var base = type[0];
  var args = type[1];
  var jsObj;
  if(base == "action") {
    // A nullary monadic action. Should become a nullary JS function.
    // Fay () -> function(){ return ... }
    return function(){
      return Fay$$fayToJs(args[0],Fay$$_(fayObj,true).value);
    };

  }
  else if(base == "function") {
    // A proper function.
    return function(){
      var fayFunc = fayObj;
      var return_type = args[args.length-1];
      var len = args.length;
      // If some arguments.
      if (len > 1) {
        // Apply to all the arguments.
        fayFunc = Fay$$_(fayFunc,true);
        // TODO: Perhaps we should throw an error when JS
        // passes more arguments than Haskell accepts.

        // Unserialize the JS values to Fay for the Fay callback.
        if (args == "automatic_function")
        {
          for (var i = 0; i < arguments.length; i++) {
            fayFunc = Fay$$fayToJs(["automatic"], Fay$$_(fayFunc(Fay$$jsToFay(["automatic"],arguments[i])),true));
          }
          return fayFunc;
        }

        for (var i = 0, len = len; i < len - 1 && fayFunc instanceof Function; i++) {
          fayFunc = Fay$$_(fayFunc(Fay$$jsToFay(args[i],arguments[i])),true);
        }
        // Finally, serialize the Fay return value back to JS.
        var return_base = return_type[0];
        var return_args = return_type[1];
        // If it's a monadic return value, get the value instead.
        if(return_base == "action") {
          return Fay$$fayToJs(return_args[0],fayFunc.value);
        }
        // Otherwise just serialize the value direct.
        else {
          return Fay$$fayToJs(return_type,fayFunc);
        }
      } else {
        throw new Error("Nullary function?");
      }
    };

  }
  else if(base == "string") {
    return Fay$$fayToJs_string(fayObj);
  }
  else if(base == "list") {
    // Serialize Fay list to JavaScript array.
    var arr = [];
    fayObj = Fay$$_(fayObj);
    while(fayObj instanceof Fay$$Cons) {
      arr.push(Fay$$fayToJs(args[0],fayObj.car));
      fayObj = Fay$$_(fayObj.cdr);
    }
    return arr;
  }
  else if(base == "tuple") {
    // Serialize Fay tuple to JavaScript array.
    var arr = [];
    fayObj = Fay$$_(fayObj);
    var i = 0;
    while(fayObj instanceof Fay$$Cons) {
      arr.push(Fay$$fayToJs(args[i++],fayObj.car));
      fayObj = Fay$$_(fayObj.cdr);
    }
    return arr;
  }
  else if(base == "defined") {
    fayObj = Fay$$_(fayObj);
    return fayObj instanceof Fay.FFI._Undefined
      ? undefined
      : Fay$$fayToJs(args[0],fayObj.slot1);
  }
  else if(base == "nullable") {
    fayObj = Fay$$_(fayObj);
    return fayObj instanceof Fay.FFI._Null
      ? null
      : Fay$$fayToJs(args[0],fayObj.slot1);
  }
  else if(base == "double" || base == "int" || base == "bool") {
    // Bools are unboxed.
    return Fay$$_(fayObj);
  }
  else if(base == "ptr" || base == "unknown")
    return fayObj;
  else if(base == "automatic" && fayObj instanceof Function) {
    return Fay$$fayToJs(["function", "automatic_function"], fayObj);
  }
  else if(base == "automatic" || base == "user") {
    fayObj = Fay$$_(fayObj);

    if(fayObj instanceof Fay$$Cons || fayObj === null){
      // Serialize Fay list to JavaScript array.
      var arr = [];
      while(fayObj instanceof Fay$$Cons) {
        arr.push(Fay$$fayToJs(["automatic"],fayObj.car));
        fayObj = Fay$$_(fayObj.cdr);
      }
      return arr;
    } else {
      var fayToJsFun = fayObj && fayObj.instance && Fay$$fayToJsHash[fayObj.instance];
      return fayToJsFun ? fayToJsFun(type,type[2],fayObj) : fayObj;
    }
  }

  throw new Error("Unhandled Fay->JS translation type: " + base);
}

// Stores the mappings from fay types to js objects.
// This will be populated by compiled modules.
var Fay$$fayToJsHash = {};

// Specialized serializer for string.
function Fay$$fayToJs_string(fayObj){
  // Serialize Fay string to JavaScript string.
  var str = "";
  fayObj = Fay$$_(fayObj);
  while(fayObj instanceof Fay$$Cons) {
    str += Fay$$_(fayObj.car);
    fayObj = Fay$$_(fayObj.cdr);
  }
  return str;
};
function Fay$$jsToFay_string(x){
  return Fay$$list(x)
};

// Special num/bool serializers.
function Fay$$jsToFay_int(x){return x;}
function Fay$$jsToFay_double(x){return x;}
function Fay$$jsToFay_bool(x){return x;}

function Fay$$fayToJs_int(x){return Fay$$_(x);}
function Fay$$fayToJs_double(x){return Fay$$_(x);}
function Fay$$fayToJs_bool(x){return Fay$$_(x);}

// Unserialize an object from JS to Fay.
function Fay$$jsToFay(type,jsObj){
  var base = type[0];
  var args = type[1];
  var fayObj;
  if(base == "action") {
    // Unserialize a "monadic" JavaScript return value into a monadic value.
    return new Fay$$Monad(Fay$$jsToFay(args[0],jsObj));
  }
  else if(base == "function") {
    // Unserialize a function from JavaScript to a function that Fay can call.
    // So
    //
    //    var f = function(x,y,z){ … }
    //
    // becomes something like:
    //
    //    function(x){
    //      return function(y){
    //        return function(z){
    //          return new Fay$$$(function(){
    //            return Fay$$jsToFay(f(Fay$$fayTojs(x),
    //                                  Fay$$fayTojs(y),
    //                                  Fay$$fayTojs(z))
    //    }}}}};
    var returnType = args[args.length-1];
    var funArgs = args.slice(0,-1);

    if (jsObj.length > 0) {
      var makePartial = function(args){
        return function(arg){
          var i = args.length;
          var fayArg = Fay$$fayToJs(funArgs[i],arg);
          var newArgs = args.concat([fayArg]);
          if(newArgs.length == funArgs.length) {
            return new Fay$$$(function(){
              return Fay$$jsToFay(returnType,jsObj.apply(this,newArgs));
            });
          } else {
            return makePartial(newArgs);
          }
        };
      };
      return makePartial([]);
    }
    else
      return function (arg) {
        return Fay$$jsToFay(["automatic"], jsObj(Fay$$fayToJs(["automatic"], arg)));
      };
  }
  else if(base == "string") {
    // Unserialize a JS string into Fay list (String).
    // This is a special case, when String is explicit in the type signature,
    // with `Automatic' a string would not be decoded.
    return Fay$$list(jsObj);
  }
  else if(base == "list") {
    // Unserialize a JS array into a Fay list ([a]).
    var serializedList = [];
    for (var i = 0, len = jsObj.length; i < len; i++) {
      // Unserialize each JS value into a Fay value, too.
      serializedList.push(Fay$$jsToFay(args[0],jsObj[i]));
    }
    // Pop it all in a Fay list.
    return Fay$$list(serializedList);
  }
  else if(base == "tuple") {
    // Unserialize a JS array into a Fay tuple ((a,b,c,...)).
    var serializedTuple = [];
    for (var i = 0, len = jsObj.length; i < len; i++) {
      // Unserialize each JS value into a Fay value, too.
      serializedTuple.push(Fay$$jsToFay(args[i],jsObj[i]));
    }
    // Pop it all in a Fay list.
    return Fay$$list(serializedTuple);
  }
  else if(base == "defined") {
    return jsObj === undefined
      ? new Fay.FFI._Undefined()
      : new Fay.FFI._Defined(Fay$$jsToFay(args[0],jsObj));
  }
  else if(base == "nullable") {
    return jsObj === null
      ? new Fay.FFI._Null()
      : new Fay.FFI.Nullable(Fay$$jsToFay(args[0],jsObj));
  }
  else if(base == "int") {
    // Int are unboxed, so there's no forcing to do.
    // But we can do validation that the int has no decimal places.
    // E.g. Math.round(x)!=x? throw "NOT AN INTEGER, GET OUT!"
    fayObj = Math.round(jsObj);
    if(fayObj!==jsObj) throw "Argument " + jsObj + " is not an integer!";
    return fayObj;
  }
  else if (base == "double" ||
           base == "bool" ||
           base ==  "ptr" ||
           base ==  "unknown") {
    return jsObj;
  }
  else if(base == "automatic" && jsObj instanceof Function) {
    var type = [["automatic"]];
    for (var i = 0; i < jsObj.length; i++)
      type.push(["automatic"]);
    return Fay$$jsToFay(["function", type], jsObj);
  }
  else if(base == "automatic" || base == "user") {
    if (jsObj && jsObj['instance']) {
      var jsToFayFun = Fay$$jsToFayHash[jsObj["instance"]];
      return jsToFayFun ? jsToFayFun(type,type[2],jsObj) : jsObj;
    }
    else if (jsObj instanceof Array) {
      var list = null;
      for (var i = jsObj.length - 1; i >= 0; i--) {
        list = new Fay$$Cons(Fay$$jsToFay([base], jsObj[i]), list);
      }
      return list;
    }
    else
      return jsObj;
  }

  throw new Error("Unhandled JS->Fay translation type: " + base);
}

// Stores the mappings from js objects to fay types.
// This will be populated by compiled modules.
var Fay$$jsToFayHash = {};

/*******************************************************************************
 * Lists.
 */

// Cons object.
function Fay$$Cons(car,cdr){
  this.car = car;
  this.cdr = cdr;
}

// Make a list.
function Fay$$list(xs){
  var out = null;
  for(var i=xs.length-1; i>=0;i--)
    out = new Fay$$Cons(xs[i],out);
  return out;
}

// Built-in list cons.
function Fay$$cons(x){
  return function(y){
    return new Fay$$Cons(x,y);
  };
}

// List index.
// `list' is already forced by the time it's passed to this function.
// `list' cannot be null and `index' cannot be out of bounds.
function Fay$$index(index,list){
  for(var i = 0; i < index; i++) {
    list = Fay$$_(list.cdr);
  }
  return list.car;
}

// List length.
// `list' is already forced by the time it's passed to this function.
function Fay$$listLen(list,max){
  for(var i = 0; list !== null && i < max + 1; i++) {
    list = Fay$$_(list.cdr);
  }
  return i == max;
}

/*******************************************************************************
 * Numbers.
 */

// Built-in *.
function Fay$$mult(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) * Fay$$_(y);
    });
  };
}

function Fay$$mult$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) * Fay$$_(y);
  });

}

// Built-in +.
function Fay$$add(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) + Fay$$_(y);
    });
  };
}

// Built-in +.
function Fay$$add$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) + Fay$$_(y);
  });

}

// Built-in -.
function Fay$$sub(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) - Fay$$_(y);
    });
  };
}
// Built-in -.
function Fay$$sub$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) - Fay$$_(y);
  });

}

// Built-in /.
function Fay$$divi(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) / Fay$$_(y);
    });
  };
}

// Built-in /.
function Fay$$divi$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) / Fay$$_(y);
  });

}

/*******************************************************************************
 * Booleans.
 */

// Are two values equal?
function Fay$$equal(lit1, lit2) {
  // Simple case
  lit1 = Fay$$_(lit1);
  lit2 = Fay$$_(lit2);
  if (lit1 === lit2) {
    return true;
  }
  // General case
  if (lit1 instanceof Array) {
    if (lit1.length != lit2.length) return false;
    for (var len = lit1.length, i = 0; i < len; i++) {
      if (!Fay$$equal(lit1[i], lit2[i])) return false;
    }
    return true;
  } else if (lit1 instanceof Fay$$Cons && lit2 instanceof Fay$$Cons) {
    do {
      if (!Fay$$equal(lit1.car,lit2.car))
        return false;
      lit1 = Fay$$_(lit1.cdr), lit2 = Fay$$_(lit2.cdr);
      if (lit1 === null || lit2 === null)
        return lit1 === lit2;
    } while (true);
  } else if (typeof lit1 == 'object' && typeof lit2 == 'object' && lit1 && lit2 &&
             lit1.instance === lit2.instance) {
    for(var x in lit1) {
      if(!Fay$$equal(lit1[x],lit2[x]))
        return false;
    }
    return true;
  } else {
    return false;
  }
}

// Built-in ==.
function Fay$$eq(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$equal(x,y);
    });
  };
}

function Fay$$eq$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$equal(x,y);
  });

}

// Built-in /=.
function Fay$$neq(x){
  return function(y){
    return new Fay$$$(function(){
      return !(Fay$$equal(x,y));
    });
  };
}

// Built-in /=.
function Fay$$neq$36$uncurried(x,y){

  return new Fay$$$(function(){
    return !(Fay$$equal(x,y));
  });

}

// Built-in >.
function Fay$$gt(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) > Fay$$_(y);
    });
  };
}

// Built-in >.
function Fay$$gt$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) > Fay$$_(y);
  });

}

// Built-in <.
function Fay$$lt(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) < Fay$$_(y);
    });
  };
}


// Built-in <.
function Fay$$lt$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) < Fay$$_(y);
  });

}


// Built-in >=.
function Fay$$gte(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) >= Fay$$_(y);
    });
  };
}

// Built-in >=.
function Fay$$gte$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) >= Fay$$_(y);
  });

}

// Built-in <=.
function Fay$$lte(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) <= Fay$$_(y);
    });
  };
}

// Built-in <=.
function Fay$$lte$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) <= Fay$$_(y);
  });

}

// Built-in &&.
function Fay$$and(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) && Fay$$_(y);
    });
  };
}

// Built-in &&.
function Fay$$and$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) && Fay$$_(y);
  });
  ;
}

// Built-in ||.
function Fay$$or(x){
  return function(y){
    return new Fay$$$(function(){
      return Fay$$_(x) || Fay$$_(y);
    });
  };
}

// Built-in ||.
function Fay$$or$36$uncurried(x,y){

  return new Fay$$$(function(){
    return Fay$$_(x) || Fay$$_(y);
  });

}

/*******************************************************************************
 * Mutable references.
 */

// Make a new mutable reference.
function Fay$$Ref(x){
  this.value = x;
}

// Write to the ref.
function Fay$$writeRef(ref,x){
  ref.value = x;
}

// Get the value from the ref.
function Fay$$readRef(ref,x){
  return ref.value;
}

/*******************************************************************************
 * Dates.
 */
function Fay$$date(str){
  return window.Date.parse(str);
}

/*******************************************************************************
 * Application code.
 */

var Data = {};
Data.Data = {};
var Fay = {};
Fay.FFI = {};
Fay.FFI._Nullable = function Nullable(slot1){
  this.slot1 = slot1;
};
Fay.FFI._Nullable.prototype.instance = "Nullable";
Fay.FFI.Nullable = function(slot1){
  return new Fay$$$(function(){
    return new Fay.FFI._Nullable(slot1);
  });
};
Fay.FFI._Null = function Null(){
};
Fay.FFI._Null.prototype.instance = "Null";
Fay.FFI.Null = new Fay$$$(function(){
  return new Fay.FFI._Null();
});
Fay.FFI._Defined = function Defined(slot1){
  this.slot1 = slot1;
};
Fay.FFI._Defined.prototype.instance = "Defined";
Fay.FFI.Defined = function(slot1){
  return new Fay$$$(function(){
    return new Fay.FFI._Defined(slot1);
  });
};
Fay.FFI._Undefined = function Undefined(){
};
Fay.FFI._Undefined.prototype.instance = "Undefined";
Fay.FFI.Undefined = new Fay$$$(function(){
  return new Fay.FFI._Undefined();
});
Fay$$objConcat(Fay$$fayToJsHash,{"Nullable": function(type,argTypes,_obj){
  var obj_ = {"instance": "Nullable"};
  var obj_slot1 = Fay$$fayToJs(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"Null": function(type,argTypes,_obj){
  var obj_ = {"instance": "Null"};
  return obj_;
},"Defined": function(type,argTypes,_obj){
  var obj_ = {"instance": "Defined"};
  var obj_slot1 = Fay$$fayToJs(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"Undefined": function(type,argTypes,_obj){
  var obj_ = {"instance": "Undefined"};
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"Nullable": function(type,argTypes,obj){
  return new Fay.FFI._Nullable(Fay$$jsToFay(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],obj["slot1"]));
},"Null": function(type,argTypes,obj){
  return new Fay.FFI._Null();
},"Defined": function(type,argTypes,obj){
  return new Fay.FFI._Defined(Fay$$jsToFay(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],obj["slot1"]));
},"Undefined": function(type,argTypes,obj){
  return new Fay.FFI._Undefined();
}});
var Prelude = {};
Prelude._Just = function Just(slot1){
  this.slot1 = slot1;
};
Prelude._Just.prototype.instance = "Just";
Prelude.Just = function(slot1){
  return new Fay$$$(function(){
    return new Prelude._Just(slot1);
  });
};
Prelude._Nothing = function Nothing(){
};
Prelude._Nothing.prototype.instance = "Nothing";
Prelude.Nothing = new Fay$$$(function(){
  return new Prelude._Nothing();
});
Prelude._Left = function Left(slot1){
  this.slot1 = slot1;
};
Prelude._Left.prototype.instance = "Left";
Prelude.Left = function(slot1){
  return new Fay$$$(function(){
    return new Prelude._Left(slot1);
  });
};
Prelude._Right = function Right(slot1){
  this.slot1 = slot1;
};
Prelude._Right.prototype.instance = "Right";
Prelude.Right = function(slot1){
  return new Fay$$$(function(){
    return new Prelude._Right(slot1);
  });
};
Prelude.maybe = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        if (Fay$$_($p3) instanceof Prelude._Nothing) {
          var m = $p1;
          return m;
        }
        if (Fay$$_($p3) instanceof Prelude._Just) {
          var x = Fay$$_($p3).slot1;
          var f = $p2;
          return Fay$$_(f)(x);
        }
        throw ["unhandled case in maybe",[$p1,$p2,$p3]];
      });
    };
  };
};
Prelude.$62$$62$$61$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return Fay$$_(Fay$$bind($p1)($p2));
    });
  };
};
Prelude.$62$$62$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return Fay$$_(Fay$$then($p1)($p2));
    });
  };
};
Prelude.$_return = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["unknown"],Fay$$return(Fay$$fayToJs(["unknown"],$p1))));
  });
};
Prelude.fail = new Fay$$$(function(){
  return Prelude.error;
});
Prelude.when = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var m = $p2;
      var p = $p1;
      return Fay$$_(p) ? Fay$$_(Fay$$_(Fay$$then)(m))(Fay$$_(Fay$$$_return)(Fay$$unit)) : Fay$$_(Fay$$$_return)(Fay$$unit);
    });
  };
};
Prelude.forM_ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var m = $p2;
      var $tmp1 = Fay$$_($p1);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(m)(x)))(Fay$$_(Fay$$_(Prelude.forM_)(xs))(m));
      }
      if (Fay$$_($p1) === null) {
        return Fay$$_(Fay$$$_return)(Fay$$unit);
      }
      throw ["unhandled case in forM_",[$p1,$p2]];
    });
  };
};
Prelude.mapM_ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var m = $p1;
        return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(m)(x)))(Fay$$_(Fay$$_(Prelude.mapM_)(m))(xs));
      }
      if (Fay$$_($p2) === null) {
        return Fay$$_(Fay$$$_return)(Fay$$unit);
      }
      throw ["unhandled case in mapM_",[$p1,$p2]];
    });
  };
};
Prelude.$61$$60$$60$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var x = $p2;
      var f = $p1;
      return Fay$$_(Fay$$_(Fay$$bind)(x))(f);
    });
  };
};
Prelude.sequence = function($p1){
  return new Fay$$$(function(){
    var ms = $p1;
    return (function(){
      var k = function($p1){
        return function($p2){
          return new Fay$$$(function(){
            var m$39$ = $p2;
            var m = $p1;
            return Fay$$_(Fay$$_(Fay$$bind)(m))(function($p1){
              var x = $p1;
              return Fay$$_(Fay$$_(Fay$$bind)(m$39$))(function($p1){
                var xs = $p1;
                return Fay$$_(Fay$$$_return)(Fay$$_(Fay$$_(Fay$$cons)(x))(xs));
              });
            });
          });
        };
      };
      return Fay$$_(Fay$$_(Fay$$_(Prelude.foldr)(k))(Fay$$_(Fay$$$_return)(null)))(ms);
    })();
  });
};
Prelude.sequence_ = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Fay$$$_return)(Fay$$unit);
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var m = $tmp1.car;
      var ms = $tmp1.cdr;
      return Fay$$_(Fay$$_(Fay$$then)(m))(Fay$$_(Prelude.sequence_)(ms));
    }
    throw ["unhandled case in sequence_",[$p1]];
  });
};
Prelude._GT = function GT(){
};
Prelude._GT.prototype.instance = "GT";
Prelude.GT = new Fay$$$(function(){
  return new Prelude._GT();
});
Prelude._LT = function LT(){
};
Prelude._LT.prototype.instance = "LT";
Prelude.LT = new Fay$$$(function(){
  return new Prelude._LT();
});
Prelude._EQ = function EQ(){
};
Prelude._EQ.prototype.instance = "EQ";
Prelude.EQ = new Fay$$$(function(){
  return new Prelude._EQ();
});
Prelude.compare = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Fay$$gt)(x))(y)) ? Prelude.GT : Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(x))(y)) ? Prelude.LT : Prelude.EQ;
    });
  };
};
Prelude.succ = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$add)(x))(1);
  });
};
Prelude.pred = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$sub)(x))(1);
  });
};
Prelude.enumFrom = function($p1){
  return new Fay$$$(function(){
    var i = $p1;
    return Fay$$_(Fay$$_(Fay$$cons)(i))(Fay$$_(Prelude.enumFrom)(Fay$$_(Fay$$_(Fay$$add)(i))(1)));
  });
};
Prelude.enumFromTo = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var n = $p2;
      var i = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Fay$$gt)(i))(n)) ? null : Fay$$_(Fay$$_(Fay$$cons)(i))(Fay$$_(Fay$$_(Prelude.enumFromTo)(Fay$$_(Fay$$_(Fay$$add)(i))(1)))(n));
    });
  };
};
Prelude.enumFromBy = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var by = $p2;
      var fr = $p1;
      return Fay$$_(Fay$$_(Fay$$cons)(fr))(Fay$$_(Fay$$_(Prelude.enumFromBy)(Fay$$_(Fay$$_(Fay$$add)(fr))(by)))(by));
    });
  };
};
Prelude.enumFromThen = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var th = $p2;
      var fr = $p1;
      return Fay$$_(Fay$$_(Prelude.enumFromBy)(fr))(Fay$$_(Fay$$_(Fay$$sub)(th))(fr));
    });
  };
};
Prelude.enumFromByTo = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var to = $p3;
        var by = $p2;
        var fr = $p1;
        return (function(){
          var neg = function($p1){
            return new Fay$$$(function(){
              var x = $p1;
              return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(x))(to)) ? null : Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(neg)(Fay$$_(Fay$$_(Fay$$add)(x))(by)));
            });
          };
          var pos = function($p1){
            return new Fay$$$(function(){
              var x = $p1;
              return Fay$$_(Fay$$_(Fay$$_(Fay$$gt)(x))(to)) ? null : Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(pos)(Fay$$_(Fay$$_(Fay$$add)(x))(by)));
            });
          };
          return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(by))(0)) ? Fay$$_(neg)(fr) : Fay$$_(pos)(fr);
        })();
      });
    };
  };
};
Prelude.enumFromThenTo = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var to = $p3;
        var th = $p2;
        var fr = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Prelude.enumFromByTo)(fr))(Fay$$_(Fay$$_(Fay$$sub)(th))(fr)))(to);
      });
    };
  };
};
Prelude.fromIntegral = function($p1){
  return new Fay$$$(function(){
    return $p1;
  });
};
Prelude.fromInteger = function($p1){
  return new Fay$$$(function(){
    return $p1;
  });
};
Prelude.not = function($p1){
  return new Fay$$$(function(){
    var p = $p1;
    return Fay$$_(p) ? false : true;
  });
};
Prelude.otherwise = true;
Prelude.show = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_string(JSON.stringify(Fay$$fayToJs(["automatic"],$p1)));
  });
};
Prelude.error = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay(["unknown"],(function() { throw Fay$$fayToJs_string($p1) })());
  });
};
Prelude.$_undefined = new Fay$$$(function(){
  return Fay$$_(Prelude.error)(Fay$$list("Prelude.undefined"));
});
Prelude.either = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        if (Fay$$_($p3) instanceof Prelude._Left) {
          var a = Fay$$_($p3).slot1;
          var f = $p1;
          return Fay$$_(f)(a);
        }
        if (Fay$$_($p3) instanceof Prelude._Right) {
          var b = Fay$$_($p3).slot1;
          var g = $p2;
          return Fay$$_(g)(b);
        }
        throw ["unhandled case in either",[$p1,$p2,$p3]];
      });
    };
  };
};
Prelude.until = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var x = $p3;
        var f = $p2;
        var p = $p1;
        return Fay$$_(Fay$$_(p)(x)) ? x : Fay$$_(Fay$$_(Fay$$_(Prelude.until)(p))(f))(Fay$$_(f)(x));
      });
    };
  };
};
Prelude.$36$$33$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var x = $p2;
      var f = $p1;
      return Fay$$_(Fay$$_(Fay$$seq)(x))(Fay$$_(f)(x));
    });
  };
};
Prelude.$_const = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var a = $p1;
      return a;
    });
  };
};
Prelude.id = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return x;
  });
};
Prelude.$46$ = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var x = $p3;
        var g = $p2;
        var f = $p1;
        return Fay$$_(f)(Fay$$_(g)(x));
      });
    };
  };
};
Prelude.$36$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var x = $p2;
      var f = $p1;
      return Fay$$_(f)(x);
    });
  };
};
Prelude.flip = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var y = $p3;
        var x = $p2;
        var f = $p1;
        return Fay$$_(Fay$$_(f)(y))(x);
      });
    };
  };
};
Prelude.curry = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var y = $p3;
        var x = $p2;
        var f = $p1;
        return Fay$$_(f)(Fay$$list([x,y]));
      });
    };
  };
};
Prelude.uncurry = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var p = $p2;
      var f = $p1;
      return (function($tmp1){
        if (Fay$$listLen(Fay$$_($tmp1),2)) {
          var x = Fay$$index(0,Fay$$_($tmp1));
          var y = Fay$$index(1,Fay$$_($tmp1));
          return Fay$$_(Fay$$_(f)(x))(y);
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(p);
    });
  };
};
Prelude.snd = function($p1){
  return new Fay$$$(function(){
    if (Fay$$listLen(Fay$$_($p1),2)) {
      var x = Fay$$index(1,Fay$$_($p1));
      return x;
    }
    throw ["unhandled case in snd",[$p1]];
  });
};
Prelude.fst = function($p1){
  return new Fay$$$(function(){
    if (Fay$$listLen(Fay$$_($p1),2)) {
      var x = Fay$$index(0,Fay$$_($p1));
      return x;
    }
    throw ["unhandled case in fst",[$p1]];
  });
};
Prelude.div = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      if (Fay$$_(Fay$$_(Fay$$_(Fay$$and)(Fay$$_(Fay$$_(Fay$$gt)(x))(0)))(Fay$$_(Fay$$_(Fay$$lt)(y))(0)))) {
        return Fay$$_(Fay$$_(Fay$$sub)(Fay$$_(Fay$$_(Prelude.quot)(Fay$$_(Fay$$_(Fay$$sub)(x))(1)))(y)))(1);
      } else {if (Fay$$_(Fay$$_(Fay$$_(Fay$$and)(Fay$$_(Fay$$_(Fay$$lt)(x))(0)))(Fay$$_(Fay$$_(Fay$$gt)(y))(0)))) {
          return Fay$$_(Fay$$_(Fay$$sub)(Fay$$_(Fay$$_(Prelude.quot)(Fay$$_(Fay$$_(Fay$$add)(x))(1)))(y)))(1);
        }
      }
      var y = $p2;
      var x = $p1;
      return Fay$$_(Fay$$_(Prelude.quot)(x))(y);
    });
  };
};
Prelude.mod = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      if (Fay$$_(Fay$$_(Fay$$_(Fay$$and)(Fay$$_(Fay$$_(Fay$$gt)(x))(0)))(Fay$$_(Fay$$_(Fay$$lt)(y))(0)))) {
        return Fay$$_(Fay$$_(Fay$$add)(Fay$$_(Fay$$_(Fay$$add)(Fay$$_(Fay$$_(Prelude.rem)(Fay$$_(Fay$$_(Fay$$sub)(x))(1)))(y)))(y)))(1);
      } else {if (Fay$$_(Fay$$_(Fay$$_(Fay$$and)(Fay$$_(Fay$$_(Fay$$lt)(x))(0)))(Fay$$_(Fay$$_(Fay$$gt)(y))(0)))) {
          return Fay$$_(Fay$$_(Fay$$sub)(Fay$$_(Fay$$_(Fay$$add)(Fay$$_(Fay$$_(Prelude.rem)(Fay$$_(Fay$$_(Fay$$add)(x))(1)))(y)))(y)))(1);
        }
      }
      var y = $p2;
      var x = $p1;
      return Fay$$_(Fay$$_(Prelude.rem)(x))(y);
    });
  };
};
Prelude.divMod = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      if (Fay$$_(Fay$$_(Fay$$_(Fay$$and)(Fay$$_(Fay$$_(Fay$$gt)(x))(0)))(Fay$$_(Fay$$_(Fay$$lt)(y))(0)))) {
        return (function($tmp1){
          if (Fay$$listLen(Fay$$_($tmp1),2)) {
            var q = Fay$$index(0,Fay$$_($tmp1));
            var r = Fay$$index(1,Fay$$_($tmp1));
            return Fay$$list([Fay$$_(Fay$$_(Fay$$sub)(q))(1),Fay$$_(Fay$$_(Fay$$add)(Fay$$_(Fay$$_(Fay$$add)(r))(y)))(1)]);
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(Fay$$_(Fay$$_(Prelude.quotRem)(Fay$$_(Fay$$_(Fay$$sub)(x))(1)))(y));
      } else {if (Fay$$_(Fay$$_(Fay$$_(Fay$$and)(Fay$$_(Fay$$_(Fay$$lt)(x))(0)))(Fay$$_(Fay$$_(Fay$$gt)(y))(1)))) {
          return (function($tmp1){
            if (Fay$$listLen(Fay$$_($tmp1),2)) {
              var q = Fay$$index(0,Fay$$_($tmp1));
              var r = Fay$$index(1,Fay$$_($tmp1));
              return Fay$$list([Fay$$_(Fay$$_(Fay$$sub)(q))(1),Fay$$_(Fay$$_(Fay$$sub)(Fay$$_(Fay$$_(Fay$$add)(r))(y)))(1)]);
            }
            return (function(){ throw (["unhandled case",$tmp1]); })();
          })(Fay$$_(Fay$$_(Prelude.quotRem)(Fay$$_(Fay$$_(Fay$$add)(x))(1)))(y));
        }
      }
      var y = $p2;
      var x = $p1;
      return Fay$$_(Fay$$_(Prelude.quotRem)(x))(y);
    });
  };
};
Prelude.min = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return Fay$$jsToFay(["unknown"],Math.min(Fay$$_(Fay$$fayToJs(["unknown"],$p1)),Fay$$_(Fay$$fayToJs(["unknown"],$p2))));
    });
  };
};
Prelude.max = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return Fay$$jsToFay(["unknown"],Math.max(Fay$$_(Fay$$fayToJs(["unknown"],$p1)),Fay$$_(Fay$$fayToJs(["unknown"],$p2))));
    });
  };
};
Prelude.recip = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$divi)(1))(x);
  });
};
Prelude.negate = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return (-(Fay$$_(x)));
  });
};
Prelude.abs = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(x))(0)) ? Fay$$_(Prelude.negate)(x) : x;
  });
};
Prelude.signum = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$_(Fay$$gt)(x))(0)) ? 1 : Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(x))(0)) ? 0 : (-(1));
  });
};
Prelude.pi = new Fay$$$(function(){
  return Fay$$jsToFay_double(Math.PI);
});
Prelude.exp = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.exp(Fay$$fayToJs_double($p1)));
  });
};
Prelude.sqrt = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.sqrt(Fay$$fayToJs_double($p1)));
  });
};
Prelude.log = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.log(Fay$$fayToJs_double($p1)));
  });
};
Prelude.$42$$42$ = new Fay$$$(function(){
  return Prelude.unsafePow;
});
Prelude.$94$$94$ = new Fay$$$(function(){
  return Prelude.unsafePow;
});
Prelude.unsafePow = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return Fay$$jsToFay(["unknown"],Math.pow(Fay$$_(Fay$$fayToJs(["unknown"],$p1)),Fay$$_(Fay$$fayToJs(["unknown"],$p2))));
    });
  };
};
Prelude.$94$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var b = $p2;
      var a = $p1;
      if (Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(b))(0))) {
        return Fay$$_(Prelude.error)(Fay$$list("(^): negative exponent"));
      } else {if (Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(b))(0))) {
          return 1;
        } else {if (Fay$$_(Fay$$_(Prelude.even)(b))) {
            return (function(){
              return new Fay$$$(function(){
                var x = new Fay$$$(function(){
                  return Fay$$_(Fay$$_(Prelude.$94$)(a))(Fay$$_(Fay$$_(Prelude.quot)(b))(2));
                });
                return Fay$$_(Fay$$_(Fay$$mult)(x))(x);
              });
            })();
          }
        }
      }
      var b = $p2;
      var a = $p1;
      return Fay$$_(Fay$$_(Fay$$mult)(a))(Fay$$_(Fay$$_(Prelude.$94$)(a))(Fay$$_(Fay$$_(Fay$$sub)(b))(1)));
    });
  };
};
Prelude.logBase = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var x = $p2;
      var b = $p1;
      return Fay$$_(Fay$$_(Fay$$divi)(Fay$$_(Prelude.log)(x)))(Fay$$_(Prelude.log)(b));
    });
  };
};
Prelude.sin = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.sin(Fay$$fayToJs_double($p1)));
  });
};
Prelude.tan = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.tan(Fay$$fayToJs_double($p1)));
  });
};
Prelude.cos = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.cos(Fay$$fayToJs_double($p1)));
  });
};
Prelude.asin = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.asin(Fay$$fayToJs_double($p1)));
  });
};
Prelude.atan = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.atan(Fay$$fayToJs_double($p1)));
  });
};
Prelude.acos = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_double(Math.acos(Fay$$fayToJs_double($p1)));
  });
};
Prelude.sinh = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$divi)(Fay$$_(Fay$$_(Fay$$sub)(Fay$$_(Prelude.exp)(x)))(Fay$$_(Prelude.exp)((-(Fay$$_(x)))))))(2);
  });
};
Prelude.tanh = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return (function(){
      return new Fay$$$(function(){
        var a = new Fay$$$(function(){
          return Fay$$_(Prelude.exp)(x);
        });
        var b = new Fay$$$(function(){
          return Fay$$_(Prelude.exp)((-(Fay$$_(x))));
        });
        return Fay$$_(Fay$$_(Fay$$divi)(Fay$$_(Fay$$_(Fay$$sub)(a))(b)))(Fay$$_(Fay$$_(Fay$$add)(a))(b));
      });
    })();
  });
};
Prelude.cosh = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$divi)(Fay$$_(Fay$$_(Fay$$add)(Fay$$_(Prelude.exp)(x)))(Fay$$_(Prelude.exp)((-(Fay$$_(x)))))))(2);
  });
};
Prelude.asinh = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Prelude.log)(Fay$$_(Fay$$_(Fay$$add)(x))(Fay$$_(Prelude.sqrt)(Fay$$_(Fay$$_(Fay$$add)(Fay$$_(Fay$$_(Prelude.$42$$42$)(x))(2)))(1))));
  });
};
Prelude.atanh = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$divi)(Fay$$_(Prelude.log)(Fay$$_(Fay$$_(Fay$$divi)(Fay$$_(Fay$$_(Fay$$add)(1))(x)))(Fay$$_(Fay$$_(Fay$$sub)(1))(x)))))(2);
  });
};
Prelude.acosh = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Prelude.log)(Fay$$_(Fay$$_(Fay$$add)(x))(Fay$$_(Prelude.sqrt)(Fay$$_(Fay$$_(Fay$$sub)(Fay$$_(Fay$$_(Prelude.$42$$42$)(x))(2)))(1))));
  });
};
Prelude.properFraction = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return (function(){
      return new Fay$$$(function(){
        var a = new Fay$$$(function(){
          return Fay$$_(Prelude.truncate)(x);
        });
        return Fay$$list([a,Fay$$_(Fay$$_(Fay$$sub)(x))(Fay$$_(Prelude.fromIntegral)(a))]);
      });
    })();
  });
};
Prelude.truncate = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(x))(0)) ? Fay$$_(Prelude.ceiling)(x) : Fay$$_(Prelude.floor)(x);
  });
};
Prelude.round = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_int(Math.round(Fay$$fayToJs_double($p1)));
  });
};
Prelude.ceiling = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_int(Math.ceil(Fay$$fayToJs_double($p1)));
  });
};
Prelude.floor = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_int(Math.floor(Fay$$fayToJs_double($p1)));
  });
};
Prelude.subtract = new Fay$$$(function(){
  return Fay$$_(Prelude.flip)(Fay$$sub);
});
Prelude.even = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$eq)(Fay$$_(Fay$$_(Prelude.rem)(x))(2)))(0);
  });
};
Prelude.odd = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Prelude.not)(Fay$$_(Prelude.even)(x));
  });
};
Prelude.gcd = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var b = $p2;
      var a = $p1;
      return (function(){
        var go = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              if (Fay$$_($p2) === 0) {
                var x = $p1;
                return x;
              }
              var y = $p2;
              var x = $p1;
              return Fay$$_(Fay$$_(go)(y))(Fay$$_(Fay$$_(Prelude.rem)(x))(y));
            });
          };
        };
        return Fay$$_(Fay$$_(go)(Fay$$_(Prelude.abs)(a)))(Fay$$_(Prelude.abs)(b));
      })();
    });
  };
};
Prelude.quot = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(y))(0)) ? Fay$$_(Prelude.error)(Fay$$list("Division by zero")) : Fay$$_(Fay$$_(Prelude.quot$39$)(x))(y);
    });
  };
};
Prelude.quot$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return Fay$$jsToFay_int(~~(Fay$$fayToJs_int($p1)/Fay$$fayToJs_int($p2)));
    });
  };
};
Prelude.quotRem = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      return Fay$$list([Fay$$_(Fay$$_(Prelude.quot)(x))(y),Fay$$_(Fay$$_(Prelude.rem)(x))(y)]);
    });
  };
};
Prelude.rem = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(y))(0)) ? Fay$$_(Prelude.error)(Fay$$list("Division by zero")) : Fay$$_(Fay$$_(Prelude.rem$39$)(x))(y);
    });
  };
};
Prelude.rem$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return Fay$$jsToFay_int(Fay$$fayToJs_int($p1) % Fay$$fayToJs_int($p2));
    });
  };
};
Prelude.lcm = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === 0) {
        return 0;
      }
      if (Fay$$_($p1) === 0) {
        return 0;
      }
      var b = $p2;
      var a = $p1;
      return Fay$$_(Prelude.abs)(Fay$$_(Fay$$_(Fay$$mult)(Fay$$_(Fay$$_(Prelude.quot)(a))(Fay$$_(Fay$$_(Prelude.gcd)(a))(b))))(b));
    });
  };
};
Prelude.find = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var p = $p1;
        return Fay$$_(Fay$$_(p)(x)) ? Fay$$_(Prelude.Just)(x) : Fay$$_(Fay$$_(Prelude.find)(p))(xs);
      }
      if (Fay$$_($p2) === null) {
        return Prelude.Nothing;
      }
      throw ["unhandled case in find",[$p1,$p2]];
    });
  };
};
Prelude.filter = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var p = $p1;
        return Fay$$_(Fay$$_(p)(x)) ? Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.filter)(p))(xs)) : Fay$$_(Fay$$_(Prelude.filter)(p))(xs);
      }
      if (Fay$$_($p2) === null) {
        return null;
      }
      throw ["unhandled case in filter",[$p1,$p2]];
    });
  };
};
Prelude.$_null = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return true;
    }
    return false;
  });
};
Prelude.map = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var f = $p1;
        return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(f)(x)))(Fay$$_(Fay$$_(Prelude.map)(f))(xs));
      }
      throw ["unhandled case in map",[$p1,$p2]];
    });
  };
};
Prelude.nub = function($p1){
  return new Fay$$$(function(){
    var ls = $p1;
    return Fay$$_(Fay$$_(Prelude.nub$39$)(ls))(null);
  });
};
Prelude.nub$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p1) === null) {
        return null;
      }
      var ls = $p2;
      var $tmp1 = Fay$$_($p1);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        return Fay$$_(Fay$$_(Fay$$_(Prelude.elem)(x))(ls)) ? Fay$$_(Fay$$_(Prelude.nub$39$)(xs))(ls) : Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.nub$39$)(xs))(Fay$$_(Fay$$_(Fay$$cons)(x))(ls)));
      }
      throw ["unhandled case in nub'",[$p1,$p2]];
    });
  };
};
Prelude.elem = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var y = $tmp1.car;
        var ys = $tmp1.cdr;
        var x = $p1;
        return Fay$$_(Fay$$_(Fay$$or)(Fay$$_(Fay$$_(Fay$$eq)(x))(y)))(Fay$$_(Fay$$_(Prelude.elem)(x))(ys));
      }
      if (Fay$$_($p2) === null) {
        return false;
      }
      throw ["unhandled case in elem",[$p1,$p2]];
    });
  };
};
Prelude.notElem = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var ys = $p2;
      var x = $p1;
      return Fay$$_(Prelude.not)(Fay$$_(Fay$$_(Prelude.elem)(x))(ys));
    });
  };
};
Prelude.sort = new Fay$$$(function(){
  return Fay$$_(Prelude.sortBy)(Prelude.compare);
});
Prelude.sortBy = function($p1){
  return new Fay$$$(function(){
    var cmp = $p1;
    return Fay$$_(Fay$$_(Prelude.foldr)(Fay$$_(Prelude.insertBy)(cmp)))(null);
  });
};
Prelude.insertBy = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        if (Fay$$_($p3) === null) {
          var x = $p2;
          return Fay$$list([x]);
        }
        var ys = $p3;
        var x = $p2;
        var cmp = $p1;
        return (function($tmp1){
          if (Fay$$_($tmp1) === null) {
            return Fay$$list([x]);
          }
          var $tmp2 = Fay$$_($tmp1);
          if ($tmp2 instanceof Fay$$Cons) {
            var y = $tmp2.car;
            var ys$39$ = $tmp2.cdr;
            return (function($tmp2){
              if (Fay$$_($tmp2) instanceof Prelude._GT) {
                return Fay$$_(Fay$$_(Fay$$cons)(y))(Fay$$_(Fay$$_(Fay$$_(Prelude.insertBy)(cmp))(x))(ys$39$));
              }
              return Fay$$_(Fay$$_(Fay$$cons)(x))(ys);
            })(Fay$$_(Fay$$_(cmp)(x))(y));
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(ys);
      });
    };
  };
};
Prelude.conc = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var ys = $p2;
      var $tmp1 = Fay$$_($p1);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        return Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.conc)(xs))(ys));
      }
      var ys = $p2;
      if (Fay$$_($p1) === null) {
        return ys;
      }
      throw ["unhandled case in conc",[$p1,$p2]];
    });
  };
};
Prelude.concat = new Fay$$$(function(){
  return Fay$$_(Fay$$_(Prelude.foldr)(Prelude.conc))(null);
});
Prelude.concatMap = function($p1){
  return new Fay$$$(function(){
    var f = $p1;
    return Fay$$_(Fay$$_(Prelude.foldr)(Fay$$_(Fay$$_(Prelude.$46$)(Prelude.$43$$43$))(f)))(null);
  });
};
Prelude.foldr = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        if (Fay$$_($p3) === null) {
          var z = $p2;
          return z;
        }
        var $tmp1 = Fay$$_($p3);
        if ($tmp1 instanceof Fay$$Cons) {
          var x = $tmp1.car;
          var xs = $tmp1.cdr;
          var z = $p2;
          var f = $p1;
          return Fay$$_(Fay$$_(f)(x))(Fay$$_(Fay$$_(Fay$$_(Prelude.foldr)(f))(z))(xs));
        }
        throw ["unhandled case in foldr",[$p1,$p2,$p3]];
      });
    };
  };
};
Prelude.foldr1 = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$listLen(Fay$$_($p2),1)) {
        var x = Fay$$index(0,Fay$$_($p2));
        return x;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var f = $p1;
        return Fay$$_(Fay$$_(f)(x))(Fay$$_(Fay$$_(Prelude.foldr1)(f))(xs));
      }
      if (Fay$$_($p2) === null) {
        return Fay$$_(Prelude.error)(Fay$$list("foldr1: empty list"));
      }
      throw ["unhandled case in foldr1",[$p1,$p2]];
    });
  };
};
Prelude.foldl = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        if (Fay$$_($p3) === null) {
          var z = $p2;
          return z;
        }
        var $tmp1 = Fay$$_($p3);
        if ($tmp1 instanceof Fay$$Cons) {
          var x = $tmp1.car;
          var xs = $tmp1.cdr;
          var z = $p2;
          var f = $p1;
          return Fay$$_(Fay$$_(Fay$$_(Prelude.foldl)(f))(Fay$$_(Fay$$_(f)(z))(x)))(xs);
        }
        throw ["unhandled case in foldl",[$p1,$p2,$p3]];
      });
    };
  };
};
Prelude.foldl1 = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var f = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Prelude.foldl)(f))(x))(xs);
      }
      if (Fay$$_($p2) === null) {
        return Fay$$_(Prelude.error)(Fay$$list("foldl1: empty list"));
      }
      throw ["unhandled case in foldl1",[$p1,$p2]];
    });
  };
};
Prelude.$43$$43$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var y = $p2;
      var x = $p1;
      return Fay$$_(Fay$$_(Prelude.conc)(x))(y);
    });
  };
};
Prelude.$33$$33$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var b = $p2;
      var a = $p1;
      return (function(){
        var go = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              if (Fay$$_($p1) === null) {
                return Fay$$_(Prelude.error)(Fay$$list("(!!): index too large"));
              }
              if (Fay$$_($p2) === 0) {
                var $tmp1 = Fay$$_($p1);
                if ($tmp1 instanceof Fay$$Cons) {
                  var h = $tmp1.car;
                  return h;
                }
              }
              var n = $p2;
              var $tmp1 = Fay$$_($p1);
              if ($tmp1 instanceof Fay$$Cons) {
                var t = $tmp1.cdr;
                return Fay$$_(Fay$$_(go)(t))(Fay$$_(Fay$$_(Fay$$sub)(n))(1));
              }
              throw ["unhandled case in go",[$p1,$p2]];
            });
          };
        };
        return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(b))(0)) ? Fay$$_(Prelude.error)(Fay$$list("(!!): negative index")) : Fay$$_(Fay$$_(go)(a))(b);
      })();
    });
  };
};
Prelude.head = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Prelude.error)(Fay$$list("head: empty list"));
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var h = $tmp1.car;
      return h;
    }
    throw ["unhandled case in head",[$p1]];
  });
};
Prelude.tail = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Prelude.error)(Fay$$list("tail: empty list"));
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var t = $tmp1.cdr;
      return t;
    }
    throw ["unhandled case in tail",[$p1]];
  });
};
Prelude.init = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Prelude.error)(Fay$$list("init: empty list"));
    }
    if (Fay$$listLen(Fay$$_($p1),1)) {
      var a = Fay$$index(0,Fay$$_($p1));
      return null;
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var h = $tmp1.car;
      var t = $tmp1.cdr;
      return Fay$$_(Fay$$_(Fay$$cons)(h))(Fay$$_(Prelude.init)(t));
    }
    throw ["unhandled case in init",[$p1]];
  });
};
Prelude.last = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Prelude.error)(Fay$$list("last: empty list"));
    }
    if (Fay$$listLen(Fay$$_($p1),1)) {
      var a = Fay$$index(0,Fay$$_($p1));
      return a;
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var t = $tmp1.cdr;
      return Fay$$_(Prelude.last)(t);
    }
    throw ["unhandled case in last",[$p1]];
  });
};
Prelude.iterate = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var x = $p2;
      var f = $p1;
      return Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.iterate)(f))(Fay$$_(f)(x)));
    });
  };
};
Prelude.repeat = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Prelude.repeat)(x));
  });
};
Prelude.replicate = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p1) === 0) {
        return null;
      }
      var x = $p2;
      var n = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(n))(0)) ? null : Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.replicate)(Fay$$_(Fay$$_(Fay$$sub)(n))(1)))(x));
    });
  };
};
Prelude.cycle = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Prelude.error)(Fay$$list("cycle: empty list"));
    }
    var xs = $p1;
    return (function(){
      var xs$39$ = new Fay$$$(function(){
        return Fay$$_(Fay$$_(Prelude.$43$$43$)(xs))(xs$39$);
      });
      return xs$39$;
    })();
  });
};
Prelude.take = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p1) === 0) {
        return null;
      }
      if (Fay$$_($p2) === null) {
        return null;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var n = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(n))(0)) ? null : Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.take)(Fay$$_(Fay$$_(Fay$$sub)(n))(1)))(xs));
      }
      throw ["unhandled case in take",[$p1,$p2]];
    });
  };
};
Prelude.drop = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var xs = $p2;
      if (Fay$$_($p1) === 0) {
        return xs;
      }
      if (Fay$$_($p2) === null) {
        return null;
      }
      var xss = $p2;
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var n = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(n))(0)) ? xss : Fay$$_(Fay$$_(Prelude.drop)(Fay$$_(Fay$$_(Fay$$sub)(n))(1)))(xs);
      }
      throw ["unhandled case in drop",[$p1,$p2]];
    });
  };
};
Prelude.splitAt = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var xs = $p2;
      if (Fay$$_($p1) === 0) {
        return Fay$$list([null,xs]);
      }
      if (Fay$$_($p2) === null) {
        return Fay$$list([null,null]);
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var n = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(n))(0)) ? Fay$$list([null,Fay$$_(Fay$$_(Fay$$cons)(x))(xs)]) : (function($tmp1){
          if (Fay$$listLen(Fay$$_($tmp1),2)) {
            var a = Fay$$index(0,Fay$$_($tmp1));
            var b = Fay$$index(1,Fay$$_($tmp1));
            return Fay$$list([Fay$$_(Fay$$_(Fay$$cons)(x))(a),b]);
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(Fay$$_(Fay$$_(Prelude.splitAt)(Fay$$_(Fay$$_(Fay$$sub)(n))(1)))(xs));
      }
      throw ["unhandled case in splitAt",[$p1,$p2]];
    });
  };
};
Prelude.takeWhile = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var p = $p1;
        return Fay$$_(Fay$$_(p)(x)) ? Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.takeWhile)(p))(xs)) : null;
      }
      throw ["unhandled case in takeWhile",[$p1,$p2]];
    });
  };
};
Prelude.dropWhile = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var p = $p1;
        return Fay$$_(Fay$$_(p)(x)) ? Fay$$_(Fay$$_(Prelude.dropWhile)(p))(xs) : Fay$$_(Fay$$_(Fay$$cons)(x))(xs);
      }
      throw ["unhandled case in dropWhile",[$p1,$p2]];
    });
  };
};
Prelude.span = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return Fay$$list([null,null]);
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var p = $p1;
        return Fay$$_(Fay$$_(p)(x)) ? (function($tmp1){
          if (Fay$$listLen(Fay$$_($tmp1),2)) {
            var a = Fay$$index(0,Fay$$_($tmp1));
            var b = Fay$$index(1,Fay$$_($tmp1));
            return Fay$$list([Fay$$_(Fay$$_(Fay$$cons)(x))(a),b]);
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(Fay$$_(Fay$$_(Prelude.span)(p))(xs)) : Fay$$list([null,Fay$$_(Fay$$_(Fay$$cons)(x))(xs)]);
      }
      throw ["unhandled case in span",[$p1,$p2]];
    });
  };
};
Prelude.$_break = function($p1){
  return new Fay$$$(function(){
    var p = $p1;
    return Fay$$_(Prelude.span)(Fay$$_(Fay$$_(Prelude.$46$)(Prelude.not))(p));
  });
};
Prelude.zipWith = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var $tmp1 = Fay$$_($p3);
        if ($tmp1 instanceof Fay$$Cons) {
          var b = $tmp1.car;
          var bs = $tmp1.cdr;
          var $tmp1 = Fay$$_($p2);
          if ($tmp1 instanceof Fay$$Cons) {
            var a = $tmp1.car;
            var as = $tmp1.cdr;
            var f = $p1;
            return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(f)(a))(b)))(Fay$$_(Fay$$_(Fay$$_(Prelude.zipWith)(f))(as))(bs));
          }
        }
        return null;
      });
    };
  };
};
Prelude.zipWith3 = function($p1){
  return function($p2){
    return function($p3){
      return function($p4){
        return new Fay$$$(function(){
          var $tmp1 = Fay$$_($p4);
          if ($tmp1 instanceof Fay$$Cons) {
            var c = $tmp1.car;
            var cs = $tmp1.cdr;
            var $tmp1 = Fay$$_($p3);
            if ($tmp1 instanceof Fay$$Cons) {
              var b = $tmp1.car;
              var bs = $tmp1.cdr;
              var $tmp1 = Fay$$_($p2);
              if ($tmp1 instanceof Fay$$Cons) {
                var a = $tmp1.car;
                var as = $tmp1.cdr;
                var f = $p1;
                return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Fay$$_(f)(a))(b))(c)))(Fay$$_(Fay$$_(Fay$$_(Fay$$_(Prelude.zipWith3)(f))(as))(bs))(cs));
              }
            }
          }
          return null;
        });
      };
    };
  };
};
Prelude.zip = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var b = $tmp1.car;
        var bs = $tmp1.cdr;
        var $tmp1 = Fay$$_($p1);
        if ($tmp1 instanceof Fay$$Cons) {
          var a = $tmp1.car;
          var as = $tmp1.cdr;
          return Fay$$_(Fay$$_(Fay$$cons)(Fay$$list([a,b])))(Fay$$_(Fay$$_(Prelude.zip)(as))(bs));
        }
      }
      return null;
    });
  };
};
Prelude.zip3 = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var $tmp1 = Fay$$_($p3);
        if ($tmp1 instanceof Fay$$Cons) {
          var c = $tmp1.car;
          var cs = $tmp1.cdr;
          var $tmp1 = Fay$$_($p2);
          if ($tmp1 instanceof Fay$$Cons) {
            var b = $tmp1.car;
            var bs = $tmp1.cdr;
            var $tmp1 = Fay$$_($p1);
            if ($tmp1 instanceof Fay$$Cons) {
              var a = $tmp1.car;
              var as = $tmp1.cdr;
              return Fay$$_(Fay$$_(Fay$$cons)(Fay$$list([a,b,c])))(Fay$$_(Fay$$_(Fay$$_(Prelude.zip3)(as))(bs))(cs));
            }
          }
        }
        return null;
      });
    };
  };
};
Prelude.unzip = function($p1){
  return new Fay$$$(function(){
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      if (Fay$$listLen(Fay$$_($tmp1.car),2)) {
        var x = Fay$$index(0,Fay$$_($tmp1.car));
        var y = Fay$$index(1,Fay$$_($tmp1.car));
        var ps = $tmp1.cdr;
        return (function($tmp1){
          if (Fay$$listLen(Fay$$_($tmp1),2)) {
            var xs = Fay$$index(0,Fay$$_($tmp1));
            var ys = Fay$$index(1,Fay$$_($tmp1));
            return Fay$$list([Fay$$_(Fay$$_(Fay$$cons)(x))(xs),Fay$$_(Fay$$_(Fay$$cons)(y))(ys)]);
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(Fay$$_(Prelude.unzip)(ps));
      }
    }
    if (Fay$$_($p1) === null) {
      return Fay$$list([null,null]);
    }
    throw ["unhandled case in unzip",[$p1]];
  });
};
Prelude.unzip3 = function($p1){
  return new Fay$$$(function(){
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      if (Fay$$listLen(Fay$$_($tmp1.car),3)) {
        var x = Fay$$index(0,Fay$$_($tmp1.car));
        var y = Fay$$index(1,Fay$$_($tmp1.car));
        var z = Fay$$index(2,Fay$$_($tmp1.car));
        var ps = $tmp1.cdr;
        return (function($tmp1){
          if (Fay$$listLen(Fay$$_($tmp1),3)) {
            var xs = Fay$$index(0,Fay$$_($tmp1));
            var ys = Fay$$index(1,Fay$$_($tmp1));
            var zs = Fay$$index(2,Fay$$_($tmp1));
            return Fay$$list([Fay$$_(Fay$$_(Fay$$cons)(x))(xs),Fay$$_(Fay$$_(Fay$$cons)(y))(ys),Fay$$_(Fay$$_(Fay$$cons)(z))(zs)]);
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(Fay$$_(Prelude.unzip3)(ps));
      }
    }
    if (Fay$$_($p1) === null) {
      return Fay$$list([null,null,null]);
    }
    throw ["unhandled case in unzip3",[$p1]];
  });
};
Prelude.lines = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return null;
    }
    var s = $p1;
    return (function(){
      var isLineBreak = function($p1){
        return new Fay$$$(function(){
          var c = $p1;
          return Fay$$_(Fay$$_(Fay$$or)(Fay$$_(Fay$$_(Fay$$eq)(c))("\r")))(Fay$$_(Fay$$_(Fay$$eq)(c))("\n"));
        });
      };
      return (function($tmp1){
        if (Fay$$listLen(Fay$$_($tmp1),2)) {
          var a = Fay$$index(0,Fay$$_($tmp1));
          if (Fay$$_(Fay$$index(1,Fay$$_($tmp1))) === null) {
            return Fay$$list([a]);
          }
          var a = Fay$$index(0,Fay$$_($tmp1));
          var $tmp2 = Fay$$_(Fay$$index(1,Fay$$_($tmp1)));
          if ($tmp2 instanceof Fay$$Cons) {
            var cs = $tmp2.cdr;
            return Fay$$_(Fay$$_(Fay$$cons)(a))(Fay$$_(Prelude.lines)(cs));
          }
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(Fay$$_(Fay$$_(Prelude.$_break)(isLineBreak))(s));
    })();
  });
};
Prelude.unlines = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return null;
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var l = $tmp1.car;
      var ls = $tmp1.cdr;
      return Fay$$_(Fay$$_(Prelude.$43$$43$)(l))(Fay$$_(Fay$$_(Fay$$cons)("\n"))(Fay$$_(Prelude.unlines)(ls)));
    }
    throw ["unhandled case in unlines",[$p1]];
  });
};
Prelude.words = function($p1){
  return new Fay$$$(function(){
    var str = $p1;
    return (function(){
      var words$39$ = function($p1){
        return new Fay$$$(function(){
          if (Fay$$_($p1) === null) {
            return null;
          }
          var s = $p1;
          return (function($tmp1){
            if (Fay$$listLen(Fay$$_($tmp1),2)) {
              var a = Fay$$index(0,Fay$$_($tmp1));
              var b = Fay$$index(1,Fay$$_($tmp1));
              return Fay$$_(Fay$$_(Fay$$cons)(a))(Fay$$_(Prelude.words)(b));
            }
            return (function(){ throw (["unhandled case",$tmp1]); })();
          })(Fay$$_(Fay$$_(Prelude.$_break)(isSpace))(s));
        });
      };
      var isSpace = function($p1){
        return new Fay$$$(function(){
          var c = $p1;
          return Fay$$_(Fay$$_(Prelude.elem)(c))(Fay$$list(" \t\r\n\u000c\u000b"));
        });
      };
      return Fay$$_(words$39$)(Fay$$_(Fay$$_(Prelude.dropWhile)(isSpace))(str));
    })();
  });
};
Prelude.unwords = new Fay$$$(function(){
  return Fay$$_(Prelude.intercalate)(Fay$$list(" "));
});
Prelude.and = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return true;
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var x = $tmp1.car;
      var xs = $tmp1.cdr;
      return Fay$$_(Fay$$_(Fay$$and)(x))(Fay$$_(Prelude.and)(xs));
    }
    throw ["unhandled case in and",[$p1]];
  });
};
Prelude.or = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return false;
    }
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var x = $tmp1.car;
      var xs = $tmp1.cdr;
      return Fay$$_(Fay$$_(Fay$$or)(x))(Fay$$_(Prelude.or)(xs));
    }
    throw ["unhandled case in or",[$p1]];
  });
};
Prelude.any = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return false;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var p = $p1;
        return Fay$$_(Fay$$_(Fay$$or)(Fay$$_(p)(x)))(Fay$$_(Fay$$_(Prelude.any)(p))(xs));
      }
      throw ["unhandled case in any",[$p1,$p2]];
    });
  };
};
Prelude.all = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return true;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var p = $p1;
        return Fay$$_(Fay$$_(Fay$$and)(Fay$$_(p)(x)))(Fay$$_(Fay$$_(Prelude.all)(p))(xs));
      }
      throw ["unhandled case in all",[$p1,$p2]];
    });
  };
};
Prelude.intersperse = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var sep = $p1;
        return Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.prependToAll)(sep))(xs));
      }
      throw ["unhandled case in intersperse",[$p1,$p2]];
    });
  };
};
Prelude.prependToAll = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var sep = $p1;
        return Fay$$_(Fay$$_(Fay$$cons)(sep))(Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(Prelude.prependToAll)(sep))(xs)));
      }
      throw ["unhandled case in prependToAll",[$p1,$p2]];
    });
  };
};
Prelude.intercalate = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var xss = $p2;
      var xs = $p1;
      return Fay$$_(Prelude.concat)(Fay$$_(Fay$$_(Prelude.intersperse)(xs))(xss));
    });
  };
};
Prelude.maximum = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Prelude.error)(Fay$$list("maximum: empty list"));
    }
    var xs = $p1;
    return Fay$$_(Fay$$_(Prelude.foldl1)(Prelude.max))(xs);
  });
};
Prelude.minimum = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) === null) {
      return Fay$$_(Prelude.error)(Fay$$list("minimum: empty list"));
    }
    var xs = $p1;
    return Fay$$_(Fay$$_(Prelude.foldl1)(Prelude.min))(xs);
  });
};
Prelude.product = function($p1){
  return new Fay$$$(function(){
    var xs = $p1;
    return Fay$$_(Fay$$_(Fay$$_(Prelude.foldl)(Fay$$mult))(1))(xs);
  });
};
Prelude.sum = function($p1){
  return new Fay$$$(function(){
    var xs = $p1;
    return Fay$$_(Fay$$_(Fay$$_(Prelude.foldl)(Fay$$add))(0))(xs);
  });
};
Prelude.scanl = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var l = $p3;
        var z = $p2;
        var f = $p1;
        return Fay$$_(Fay$$_(Fay$$cons)(z))((function($tmp1){
          if (Fay$$_($tmp1) === null) {
            return null;
          }
          var $tmp2 = Fay$$_($tmp1);
          if ($tmp2 instanceof Fay$$Cons) {
            var x = $tmp2.car;
            var xs = $tmp2.cdr;
            return Fay$$_(Fay$$_(Fay$$_(Prelude.scanl)(f))(Fay$$_(Fay$$_(f)(z))(x)))(xs);
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(l));
      });
    };
  };
};
Prelude.scanl1 = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var f = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Prelude.scanl)(f))(x))(xs);
      }
      throw ["unhandled case in scanl1",[$p1,$p2]];
    });
  };
};
Prelude.scanr = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        if (Fay$$_($p3) === null) {
          var z = $p2;
          return Fay$$list([z]);
        }
        var $tmp1 = Fay$$_($p3);
        if ($tmp1 instanceof Fay$$Cons) {
          var x = $tmp1.car;
          var xs = $tmp1.cdr;
          var z = $p2;
          var f = $p1;
          return (function($tmp1){
            var $tmp2 = Fay$$_($tmp1);
            if ($tmp2 instanceof Fay$$Cons) {
              var h = $tmp2.car;
              var t = $tmp2.cdr;
              return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(f)(x))(h)))(Fay$$_(Fay$$_(Fay$$cons)(h))(t));
            }
            return Prelude.$_undefined;
          })(Fay$$_(Fay$$_(Fay$$_(Prelude.scanr)(f))(z))(xs));
        }
        throw ["unhandled case in scanr",[$p1,$p2,$p3]];
      });
    };
  };
};
Prelude.scanr1 = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      if (Fay$$listLen(Fay$$_($p2),1)) {
        var x = Fay$$index(0,Fay$$_($p2));
        return Fay$$list([x]);
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var x = $tmp1.car;
        var xs = $tmp1.cdr;
        var f = $p1;
        return (function($tmp1){
          var $tmp2 = Fay$$_($tmp1);
          if ($tmp2 instanceof Fay$$Cons) {
            var h = $tmp2.car;
            var t = $tmp2.cdr;
            return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(f)(x))(h)))(Fay$$_(Fay$$_(Fay$$cons)(h))(t));
          }
          return Prelude.$_undefined;
        })(Fay$$_(Fay$$_(Prelude.scanr1)(f))(xs));
      }
      throw ["unhandled case in scanr1",[$p1,$p2]];
    });
  };
};
Prelude.lookup = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        var _key = $p1;
        return Prelude.Nothing;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        if (Fay$$listLen(Fay$$_($tmp1.car),2)) {
          var x = Fay$$index(0,Fay$$_($tmp1.car));
          var y = Fay$$index(1,Fay$$_($tmp1.car));
          var xys = $tmp1.cdr;
          var key = $p1;
          return Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(key))(x)) ? Fay$$_(Prelude.Just)(y) : Fay$$_(Fay$$_(Prelude.lookup)(key))(xys);
        }
      }
      throw ["unhandled case in lookup",[$p1,$p2]];
    });
  };
};
Prelude.length = function($p1){
  return new Fay$$$(function(){
    var xs = $p1;
    return Fay$$_(Fay$$_(Prelude.length$39$)(0))(xs);
  });
};
Prelude.length$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var xs = $tmp1.cdr;
        var acc = $p1;
        return Fay$$_(Fay$$_(Prelude.length$39$)(Fay$$_(Fay$$_(Fay$$add)(acc))(1)))(xs);
      }
      var acc = $p1;
      return acc;
    });
  };
};
Prelude.reverse = function($p1){
  return new Fay$$$(function(){
    var $tmp1 = Fay$$_($p1);
    if ($tmp1 instanceof Fay$$Cons) {
      var x = $tmp1.car;
      var xs = $tmp1.cdr;
      return Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(Prelude.reverse)(xs)))(Fay$$list([x]));
    }
    if (Fay$$_($p1) === null) {
      return null;
    }
    throw ["unhandled case in reverse",[$p1]];
  });
};
Prelude.print = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["unknown"],(function(x) { if (console && console.log) console.log(x) })(Fay$$fayToJs(["automatic"],$p1))));
  });
};
Prelude.putStrLn = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["unknown"],(function(x) { if (console && console.log) console.log(x) })(Fay$$fayToJs_string($p1))));
  });
};
Prelude.ifThenElse = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var b = $p3;
        var a = $p2;
        var p = $p1;
        return Fay$$_(p) ? a : b;
      });
    };
  };
};
Fay$$objConcat(Fay$$fayToJsHash,{"Just": function(type,argTypes,_obj){
  var obj_ = {"instance": "Just"};
  var obj_slot1 = Fay$$fayToJs(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"Nothing": function(type,argTypes,_obj){
  var obj_ = {"instance": "Nothing"};
  return obj_;
},"Left": function(type,argTypes,_obj){
  var obj_ = {"instance": "Left"};
  var obj_slot1 = Fay$$fayToJs(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"Right": function(type,argTypes,_obj){
  var obj_ = {"instance": "Right"};
  var obj_slot1 = Fay$$fayToJs(argTypes && (argTypes)[1] ? (argTypes)[1] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"GT": function(type,argTypes,_obj){
  var obj_ = {"instance": "GT"};
  return obj_;
},"LT": function(type,argTypes,_obj){
  var obj_ = {"instance": "LT"};
  return obj_;
},"EQ": function(type,argTypes,_obj){
  var obj_ = {"instance": "EQ"};
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"Just": function(type,argTypes,obj){
  return new Prelude._Just(Fay$$jsToFay(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],obj["slot1"]));
},"Nothing": function(type,argTypes,obj){
  return new Prelude._Nothing();
},"Left": function(type,argTypes,obj){
  return new Prelude._Left(Fay$$jsToFay(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],obj["slot1"]));
},"Right": function(type,argTypes,obj){
  return new Prelude._Right(Fay$$jsToFay(argTypes && (argTypes)[1] ? (argTypes)[1] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],obj["slot1"]));
},"GT": function(type,argTypes,obj){
  return new Prelude._GT();
},"LT": function(type,argTypes,obj){
  return new Prelude._LT();
},"EQ": function(type,argTypes,obj){
  return new Prelude._EQ();
}});
var FFI = {};
var Util = {};
Util.myintersperse = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return null;
      }
      if (Fay$$listLen(Fay$$_($p2),1)) {
        var a = Fay$$index(0,Fay$$_($p2));
        return Fay$$list([a]);
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var a = $tmp1.car;
        var cs = $tmp1.cdr;
        var sep = $p1;
        return Fay$$_(Fay$$_(Fay$$cons)(a))(Fay$$_(Fay$$_(Fay$$cons)(sep))(Fay$$_(Fay$$_(Util.myintersperse)(sep))(cs)));
      }
      throw ["unhandled case in myintersperse",[$p1,$p2]];
    });
  };
};
Util.one = function($p1){
  return new Fay$$$(function(){
    var n = $p1;
    return Fay$$list([n]);
  });
};
Util.mmap = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) instanceof Prelude._Nothing) {
        return Prelude.Nothing;
      }
      if (Fay$$_($p2) instanceof Prelude._Just) {
        var a = Fay$$_($p2).slot1;
        var f = $p1;
        return Fay$$_(Prelude.Just)(Fay$$_(f)(a));
      }
      throw ["unhandled case in mmap",[$p1,$p2]];
    });
  };
};
Util.fromJust = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Prelude._Nothing) {
      return Fay$$_(Prelude.error)(Fay$$list("Bad code! Used fromJust on a Nothing value!"));
    }
    if (Fay$$_($p1) instanceof Prelude._Just) {
      var a = Fay$$_($p1).slot1;
      return a;
    }
    throw ["unhandled case in fromJust",[$p1]];
  });
};
Util._DeleteSubtree = function DeleteSubtree(){
};
Util._DeleteSubtree.prototype.instance = "DeleteSubtree";
Util.DeleteSubtree = new Fay$$$(function(){
  return new Util._DeleteSubtree();
});
Util._Descend = function Descend(){
};
Util._Descend.prototype.instance = "Descend";
Util.Descend = new Fay$$$(function(){
  return new Util._Descend();
});
Util._Replace = function Replace(slot1){
  this.slot1 = slot1;
};
Util._Replace.prototype.instance = "Replace";
Util.Replace = function(slot1){
  return new Fay$$$(function(){
    return new Util._Replace(slot1);
  });
};
Util.lwalk = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var l = $p2;
      var f = $p1;
      return (function(){
        var r = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              if (Fay$$_($p2) === null) {
                return null;
              }
              var $tmp1 = Fay$$_($p2);
              if ($tmp1 instanceof Fay$$Cons) {
                var x = $tmp1.car;
                var xs = $tmp1.cdr;
                var i = $p1;
                return (function($tmp1){
                  if (Fay$$_($tmp1) instanceof Util._DeleteSubtree) {
                    return Fay$$_(Fay$$_(r)(Fay$$_(Fay$$_(Fay$$add)(i))(1)))(xs);
                  }
                  if (Fay$$_($tmp1) instanceof Util._Descend) {
                    return Fay$$_(Fay$$_(Fay$$cons)(x))(Fay$$_(Fay$$_(r)(Fay$$_(Fay$$_(Fay$$add)(i))(1)))(xs));
                  }
                  if (Fay$$_($tmp1) instanceof Util._Replace) {
                    var a = Fay$$_($tmp1).slot1;
                    return Fay$$_(Fay$$_(Fay$$cons)(a))(Fay$$_(Fay$$_(r)(Fay$$_(Fay$$_(Fay$$add)(i))(1)))(xs));
                  }
                  return (function(){ throw (["unhandled case",$tmp1]); })();
                })(Fay$$_(Fay$$_(f)(i))(x));
              }
              throw ["unhandled case in r",[$p1,$p2]];
            });
          };
        };
        return Fay$$_(Fay$$_(r)(0))(l);
      })();
    });
  };
};
Util.mymapM = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var l = $p2;
      var f = $p1;
      return Fay$$_(Fay$$_(Prelude.$36$)(Prelude.sequence))(Fay$$_(Fay$$_(Prelude.map)(f))(l));
    });
  };
};
Util.iter = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var l = $p2;
      var f = $p1;
      return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(Fay$$_(Util.mymapM)(f))(l)))(Fay$$_(Fay$$$_return)(Fay$$unit));
    });
  };
};
Util.mapi = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var l = $p2;
      var f = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Prelude.zipWith)(f))(Prelude.enumFrom(0)))(l);
    });
  };
};
Util.prefix = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p1) === null) {
        return true;
      }
      if (Fay$$_($p2) === null) {
        return false;
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var b = $tmp1.car;
        var bs = $tmp1.cdr;
        var $tmp1 = Fay$$_($p1);
        if ($tmp1 instanceof Fay$$Cons) {
          var a = $tmp1.car;
          var as = $tmp1.cdr;
          return Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(a))(b)) ? Fay$$_(Fay$$_(Util.prefix)(as))(bs) : false;
        }
      }
      throw ["unhandled case in prefix",[$p1,$p2]];
    });
  };
};
Util.comma = new Fay$$$(function(){
  return Fay$$_(Fay$$_(Prelude.$46$)(Prelude.concat))(Fay$$_(Util.myintersperse)(Fay$$list(",")));
});
Util.uncomma1 = function($p1){
  return new Fay$$$(function(){
    if (Fay$$equal($p1,Fay$$list(""))) {
      return Prelude.Nothing;
    }
    var str = $p1;
    return (function(){
      var r = function($p1){
        return function($p2){
          return new Fay$$$(function(){
            if (Fay$$_($p2) === null) {
              var acc = $p1;
              return Fay$$list([Fay$$_(Prelude.reverse)(acc),Fay$$list("")]);
            }
            var $tmp1 = Fay$$_($p2);
            if ($tmp1 instanceof Fay$$Cons) {
              if (Fay$$_($tmp1.car) === ",") {
                var cs = $tmp1.cdr;
                var acc = $p1;
                return Fay$$list([Fay$$_(Prelude.reverse)(acc),cs]);
              }
            }
            var $tmp1 = Fay$$_($p2);
            if ($tmp1 instanceof Fay$$Cons) {
              var c = $tmp1.car;
              var cs = $tmp1.cdr;
              var acc = $p1;
              return Fay$$_(Fay$$_(r)(Fay$$_(Fay$$_(Fay$$cons)(c))(acc)))(cs);
            }
            throw ["unhandled case in r",[$p1,$p2]];
          });
        };
      };
      return Fay$$_(Prelude.Just)(Fay$$_(Fay$$_(r)(null))(str));
    })();
  });
};
Util.uncomma = function($p1){
  return new Fay$$$(function(){
    var str = $p1;
    return (function(){
      var r = function($p1){
        return function($p2){
          return new Fay$$$(function(){
            var e = $p2;
            var acc = $p1;
            return (function($tmp1){
              if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
                return Fay$$_(Prelude.reverse)(acc);
              }
              if (Fay$$_($tmp1) instanceof Prelude._Just) {
                if (Fay$$listLen(Fay$$_(Fay$$_($tmp1).slot1),2)) {
                  var s = Fay$$index(0,Fay$$_(Fay$$_($tmp1).slot1));
                  var ss = Fay$$index(1,Fay$$_(Fay$$_($tmp1).slot1));
                  return Fay$$_(Fay$$_(r)(Fay$$_(Fay$$_(Fay$$cons)(s))(acc)))(ss);
                }
              }
              return (function(){ throw (["unhandled case",$tmp1]); })();
            })(Fay$$_(Util.uncomma1)(e));
          });
        };
      };
      return Fay$$_(Fay$$_(r)(null))(str);
    })();
  });
};
Util.digit = function($p1){
  return new Fay$$$(function(){
    var c = $p1;
    return (function($tmp1){
      if (Fay$$_($tmp1) === "0") {
        return Fay$$_(Prelude.Just)(0);
      }
      if (Fay$$_($tmp1) === "1") {
        return Fay$$_(Prelude.Just)(1);
      }
      if (Fay$$_($tmp1) === "2") {
        return Fay$$_(Prelude.Just)(2);
      }
      if (Fay$$_($tmp1) === "3") {
        return Fay$$_(Prelude.Just)(3);
      }
      if (Fay$$_($tmp1) === "4") {
        return Fay$$_(Prelude.Just)(4);
      }
      if (Fay$$_($tmp1) === "5") {
        return Fay$$_(Prelude.Just)(5);
      }
      if (Fay$$_($tmp1) === "6") {
        return Fay$$_(Prelude.Just)(6);
      }
      if (Fay$$_($tmp1) === "7") {
        return Fay$$_(Prelude.Just)(7);
      }
      if (Fay$$_($tmp1) === "8") {
        return Fay$$_(Prelude.Just)(8);
      }
      if (Fay$$_($tmp1) === "9") {
        return Fay$$_(Prelude.Just)(9);
      }
      return Prelude.Nothing;
    })(c);
  });
};
Util.parseInt$39$ = function($p1){
  return new Fay$$$(function(){
    var s = $p1;
    return (function($tmp1){
      if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
        return Fay$$_(Prelude.error)(Fay$$list("parseInt failed"));
      }
      if (Fay$$_($tmp1) instanceof Prelude._Just) {
        var i = Fay$$_($tmp1).slot1;
        return i;
      }
      return (function(){ throw (["unhandled case",$tmp1]); })();
    })(Fay$$_(Util.parseInt)(s));
  });
};
Util.parseInt = function($p1){
  return new Fay$$$(function(){
    var str = $p1;
    return (function(){
      var r = function($p1){
        return function($p2){
          return function($p3){
            return new Fay$$$(function(){
              if (Fay$$_($p3) === null) {
                var a = $p1;
                return Fay$$_(Prelude.Just)(a);
              }
              var $tmp1 = Fay$$_($p3);
              if ($tmp1 instanceof Fay$$Cons) {
                var c = $tmp1.car;
                var cs = $tmp1.cdr;
                var m = $p2;
                var a = $p1;
                return (function($tmp1){
                  if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
                    return Prelude.Nothing;
                  }
                  if (Fay$$_($tmp1) instanceof Prelude._Just) {
                    var code = Fay$$_($tmp1).slot1;
                    return Fay$$_(Fay$$_(Fay$$_(r)(Fay$$_(Fay$$_(Fay$$add)(a))(Fay$$_(Fay$$_(Fay$$mult)(m))(code))))(Fay$$_(Fay$$_(Fay$$mult)(m))(10)))(cs);
                  }
                  return (function(){ throw (["unhandled case",$tmp1]); })();
                })(Fay$$_(Util.digit)(c));
              }
              throw ["unhandled case in r",[$p1,$p2,$p3]];
            });
          };
        };
      };
      return (function($tmp1){
        if (Fay$$_($tmp1) === null) {
          return Prelude.Nothing;
        }
        var l = $tmp1;
        return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Fay$$_(r)(0))(1)))(Fay$$_(Prelude.reverse)(l));
      })(str);
    })();
  });
};
Fay$$objConcat(Fay$$fayToJsHash,{"DeleteSubtree": function(type,argTypes,_obj){
  var obj_ = {"instance": "DeleteSubtree"};
  return obj_;
},"Descend": function(type,argTypes,_obj){
  var obj_ = {"instance": "Descend"};
  return obj_;
},"Replace": function(type,argTypes,_obj){
  var obj_ = {"instance": "Replace"};
  var obj_slot1 = Fay$$fayToJs(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"DeleteSubtree": function(type,argTypes,obj){
  return new Util._DeleteSubtree();
},"Descend": function(type,argTypes,obj){
  return new Util._Descend();
},"Replace": function(type,argTypes,obj){
  return new Util._Replace(Fay$$jsToFay(argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"],obj["slot1"]));
}});
var Outline = {};
Outline._Addr = function Addr(slot1){
  this.slot1 = slot1;
};
Outline._Addr.prototype.instance = "Addr";
Outline.Addr = function(slot1){
  return new Fay$$$(function(){
    return new Outline._Addr(slot1);
  });
};
Outline._OLStr = function OLStr(slot1){
  this.slot1 = slot1;
};
Outline._OLStr.prototype.instance = "OLStr";
Outline.OLStr = function(slot1){
  return new Fay$$$(function(){
    return new Outline._OLStr(slot1);
  });
};
Outline._OL = function OL(slot1,slot2){
  this.slot1 = slot1;
  this.slot2 = slot2;
};
Outline._OL.prototype.instance = "OL";
Outline.OL = function(slot1){
  return function(slot2){
    return new Fay$$$(function(){
      return new Outline._OL(slot1,slot2);
    });
  };
};
Outline._INDENT = function INDENT(){
};
Outline._INDENT.prototype.instance = "INDENT";
Outline.INDENT = new Fay$$$(function(){
  return new Outline._INDENT();
});
Outline._DEDENT = function DEDENT(){
};
Outline._DEDENT.prototype.instance = "DEDENT";
Outline.DEDENT = new Fay$$$(function(){
  return new Outline._DEDENT();
});
Outline._LINE = function LINE(slot1){
  this.slot1 = slot1;
};
Outline._LINE.prototype.instance = "LINE";
Outline.LINE = function(slot1){
  return new Fay$$$(function(){
    return new Outline._LINE(slot1);
  });
};
Outline.unols = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Outline._OLStr) {
      var s = Fay$$_($p1).slot1;
      return s;
    }
    throw ["unhandled case in unols",[$p1]];
  });
};
Outline.oltext = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Outline._OL) {
      if (Fay$$_(Fay$$_($p1).slot1) instanceof Outline._OLStr) {
        var s = Fay$$_(Fay$$_($p1).slot1).slot1;
        return s;
      }
    }
    throw ["unhandled case in oltext",[$p1]];
  });
};
Outline.addrOk = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var ol = $p2;
      var a = $p1;
      return (function($tmp1){
        if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
          return false;
        }
        if (Fay$$_($tmp1) instanceof Prelude._Just) {
          return true;
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(Fay$$_(Fay$$_(Outline.olget)(a))(ol));
    });
  };
};
Outline.addrBefore = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Outline._Addr) {
      var a = Fay$$_($p1).slot1;
      return Fay$$_(Fay$$_(Prelude.$36$)(Outline.Addr))((function($tmp1){
        if (Fay$$_($tmp1) === null) {
          return null;
        }
        var $tmp2 = Fay$$_($tmp1);
        if ($tmp2 instanceof Fay$$Cons) {
          var b = $tmp2.car;
          var bs = $tmp2.cdr;
          return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Fay$$sub)(b))(1)))(bs);
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(a));
    }
    throw ["unhandled case in addrBefore",[$p1]];
  });
};
Outline.addrAfter = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Outline._Addr) {
      var a = Fay$$_($p1).slot1;
      return Fay$$_(Fay$$_(Prelude.$36$)(Outline.Addr))((function($tmp1){
        if (Fay$$_($tmp1) === null) {
          return null;
        }
        var $tmp2 = Fay$$_($tmp1);
        if ($tmp2 instanceof Fay$$Cons) {
          var b = $tmp2.car;
          var bs = $tmp2.cdr;
          return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Fay$$add)(b))(1)))(bs);
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(a));
    }
    throw ["unhandled case in addrAfter",[$p1]];
  });
};
Outline.addrParent = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Outline._Addr) {
      var a = Fay$$_($p1).slot1;
      return Fay$$_(Fay$$_(Prelude.$36$)(Outline.Addr))((function($tmp1){
        if (Fay$$_($tmp1) === null) {
          return null;
        }
        var $tmp2 = Fay$$_($tmp1);
        if ($tmp2 instanceof Fay$$Cons) {
          var bs = $tmp2.cdr;
          return bs;
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(a));
    }
    throw ["unhandled case in addrParent",[$p1]];
  });
};
Outline.addrChild = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Outline._Addr) {
      var a = Fay$$_($p1).slot1;
      return Fay$$_(Fay$$_(Prelude.$36$)(Outline.Addr))(Fay$$_(Fay$$_(Fay$$cons)(0))(a));
    }
    throw ["unhandled case in addrChild",[$p1]];
  });
};
Outline.olget = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var ol = $p2;
      if (Fay$$_($p1) instanceof Outline._Addr) {
        var addr = Fay$$_($p1).slot1;
        return (function(){
          var r = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                var o = $p2;
                if (Fay$$_($p1) === null) {
                  return Fay$$_(Prelude.Just)(o);
                }
                if (Fay$$_($p2) instanceof Outline._OL) {
                  if (Fay$$_(Fay$$_($p2).slot2) === null) {
                    return Prelude.Nothing;
                  }
                  var sub = Fay$$_($p2).slot2;
                  var $tmp1 = Fay$$_($p1);
                  if ($tmp1 instanceof Fay$$Cons) {
                    var a = $tmp1.car;
                    var as = $tmp1.cdr;
                    return Fay$$_(Fay$$_(Prelude.or)(Fay$$list([Fay$$_(Fay$$_(Fay$$gte)(a))(Fay$$_(Prelude.length)(sub)),Fay$$_(Fay$$_(Fay$$lt)(a))(0)]))) ? Prelude.Nothing : Fay$$_(Fay$$_(r)(as))(Fay$$_(Fay$$_(Prelude.$33$$33$)(sub))(a));
                  }
                }
                throw ["unhandled case in r",[$p1,$p2]];
              });
            };
          };
          return Fay$$_(Fay$$_(r)(Fay$$_(Prelude.reverse)(addr)))(ol);
        })();
      }
      throw ["unhandled case in olget",[$p1,$p2]];
    });
  };
};
Outline.ols = function($p1){
  return new Fay$$$(function(){
    var str = $p1;
    return (function(){
      var trim = function($p1){
        return new Fay$$$(function(){
          var s = $p1;
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Prelude.map)(untab)))(Fay$$_(Fay$$_(Prelude.$36$)(Prelude.reverse))(Fay$$_(Fay$$_(Prelude.$36$)(f))(Fay$$_(Fay$$_(Prelude.$36$)(Prelude.reverse))(Fay$$_(f)(s)))));
        });
      };
      var f = function($p1){
        return new Fay$$$(function(){
          if (Fay$$equal($p1,Fay$$list(""))) {
            return Fay$$list("");
          }
          var $tmp1 = Fay$$_($p1);
          if ($tmp1 instanceof Fay$$Cons) {
            if (Fay$$_($tmp1.car) === " ") {
              var s = $tmp1.cdr;
              return Fay$$_(f)(s);
            }
          }
          var $tmp1 = Fay$$_($p1);
          if ($tmp1 instanceof Fay$$Cons) {
            if (Fay$$_($tmp1.car) === "\t") {
              var s = $tmp1.cdr;
              return Fay$$_(f)(s);
            }
          }
          var s = $p1;
          return s;
        });
      };
      var untab = function($p1){
        return new Fay$$$(function(){
          if (Fay$$_($p1) === "\t") {
            return " ";
          }
          var x = $p1;
          return x;
        });
      };
      return Fay$$_(Fay$$_(Prelude.$36$)(Outline.OLStr))((function($tmp1){
        if (Fay$$_($tmp1) === null) {
          return Fay$$list("#");
        }
        var ts = $tmp1;
        return ts;
      })(Fay$$_(trim)(str)));
    })();
  });
};
Outline.olexample = new Fay$$$(function(){
  return new Fay$$$(function(){
    var ol = function($p1){
      return function($p2){
        return new Fay$$$(function(){
          var s = $p2;
          var t = $p1;
          return Fay$$_(Fay$$_(Outline.OL)(Fay$$_(Outline.ols)(t)))(s);
        });
      };
    };
    var l = function($p1){
      return new Fay$$$(function(){
        var t = $p1;
        return Fay$$_(Fay$$_(Outline.OL)(Fay$$_(Outline.ols)(t)))(null);
      });
    };
    return Fay$$_(Fay$$_(ol)(Fay$$list("h")))(Fay$$list([Fay$$_(l)(Fay$$list("i")),Fay$$_(l)(Fay$$list("j")),Fay$$_(Fay$$_(ol)(Fay$$list("k")))(Fay$$list([Fay$$_(l)(Fay$$list("hihihi there")),Fay$$_(Fay$$_(ol)(Fay$$list("w")))(Fay$$list([Fay$$_(l)(Fay$$list("t")),Fay$$_(l)(Fay$$list("f"))]))]))]));
  });
});
Outline.addrmap = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var l = $p3;
        var f = $p2;
        if (Fay$$_($p1) instanceof Outline._Addr) {
          var a = Fay$$_($p1).slot1;
          return Fay$$_(Fay$$_(Util.mapi)(function($p1){
            var i = $p1;
            return function($p2){
              var e = $p2;
              return Fay$$_(Fay$$_(f)(Fay$$_(Outline.Addr)(Fay$$_(Fay$$_(Fay$$cons)(i))(a))))(e);
            };
          }))(l);
        }
        throw ["unhandled case in addrmap",[$p1,$p2,$p3]];
      });
    };
  };
};
Outline.olshow = function($p1){
  return new Fay$$$(function(){
    var node = $p1;
    return (function(){
      var join = new Fay$$$(function(){
        return Fay$$_(Fay$$_(Prelude.$46$)(Prelude.concat))(Fay$$_(Util.myintersperse)(Fay$$list("\n")));
      });
      var r = function($p1){
        return function($p2){
          return new Fay$$$(function(){
            if (Fay$$_($p2) instanceof Outline._OL) {
              if (Fay$$_(Fay$$_($p2).slot1) instanceof Outline._OLStr) {
                var s = Fay$$_(Fay$$_($p2).slot1).slot1;
                if (Fay$$_(Fay$$_($p2).slot2) === null) {
                  var d = $p1;
                  return Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(indent)(d)))(s);
                }
                var s = Fay$$_(Fay$$_($p2).slot1).slot1;
                var cs = Fay$$_($p2).slot2;
                var d = $p1;
                return Fay$$_(Fay$$_(Prelude.$36$)(join))(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(indent)(d)))(s)))(Fay$$_(Fay$$_(Prelude.map)(Fay$$_(r)(Fay$$_(Fay$$_(Fay$$add)(d))(1))))(cs)));
              }
            }
            throw ["unhandled case in r",[$p1,$p2]];
          });
        };
      };
      var indent = function($p1){
        return new Fay$$$(function(){
          if (Fay$$_($p1) === 0) {
            return Fay$$list("");
          }
          var n = $p1;
          return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(n))(0)) ? Prelude.$_undefined : Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$list("\t")))(Fay$$_(indent)(Fay$$_(Fay$$_(Fay$$sub)(n))(1)));
        });
      };
      return Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(Fay$$_(r)(0))(node)))(Fay$$list("\n"));
    })();
  });
};
Outline.olwalk = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var outline = $p2;
      var f = $p1;
      return (function(){
        var amap = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              var l = $p2;
              if (Fay$$_($p1) instanceof Outline._Addr) {
                var a = Fay$$_($p1).slot1;
                return Fay$$_(Fay$$_(Util.lwalk)(function($p1){
                  var i = $p1;
                  return function($p2){
                    var e = $p2;
                    return Fay$$_(Fay$$_(r)(Fay$$_(Outline.Addr)(Fay$$_(Fay$$_(Fay$$cons)(i))(a))))(e);
                  };
                }))(l);
              }
              throw ["unhandled case in amap",[$p1,$p2]];
            });
          };
        };
        var foo = function($p1){
          return new Fay$$$(function(){
            if (Fay$$_($p1) instanceof Util._Replace) {
              var x = Fay$$_($p1).slot1;
              return x;
            }
            if (Fay$$_($p1) instanceof Util._DeleteSubtree) {
              return Fay$$_(Fay$$_(Outline.OL)(Fay$$_(Outline.ols)(Fay$$list(""))))(null);
            }
            if (Fay$$_($p1) instanceof Util._Descend) {
              return Prelude.$_undefined;
            }
            throw ["unhandled case in foo",[$p1]];
          });
        };
        var descendAddr = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              if (Fay$$_($p2) instanceof Outline._OL) {
                var l = Fay$$_($p2).slot1;
                var subs = Fay$$_($p2).slot2;
                var addr = $p1;
                return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Outline.OL)(l)))(Fay$$_(Fay$$_(amap)(addr))(subs));
              }
              throw ["unhandled case in descendAddr",[$p1,$p2]];
            });
          };
        };
        var r = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              var ol = $p2;
              var a = $p1;
              return (function($tmp1){
                if (Fay$$_($tmp1) instanceof Util._DeleteSubtree) {
                  return Util.DeleteSubtree;
                }
                if (Fay$$_($tmp1) instanceof Util._Descend) {
                  return Fay$$_(Fay$$_(Prelude.$36$)(Util.Replace))(Fay$$_(Fay$$_(descendAddr)(a))(ol));
                }
                if (Fay$$_($tmp1) instanceof Util._Replace) {
                  var newNode = Fay$$_($tmp1).slot1;
                  return Fay$$_(Util.Replace)(newNode);
                }
                return (function(){ throw (["unhandled case",$tmp1]); })();
              })(Fay$$_(Fay$$_(f)(a))(ol));
            });
          };
        };
        return Fay$$_(Fay$$_(Prelude.$36$)(foo))(Fay$$_(Fay$$_(r)(Fay$$_(Outline.Addr)(null)))(outline));
      })();
    });
  };
};
Outline.olread = new Fay$$$(function(){
  return new Fay$$$(function(){
    var reorder = function($p1){
      return new Fay$$$(function(){
        var $tmp1 = Fay$$_($p1);
        if ($tmp1 instanceof Fay$$Cons) {
          var t = $tmp1.car;
          var $tmp2 = Fay$$_($tmp1.cdr);
          if ($tmp2 instanceof Fay$$Cons) {
            if (Fay$$_($tmp2.car) instanceof Outline._INDENT) {
              var ts = $tmp2.cdr;
              return Fay$$_(Fay$$_(Fay$$cons)(Outline.INDENT))(Fay$$_(Fay$$_(Fay$$cons)(t))(Fay$$_(reorder)(ts)));
            }
          }
        }
        var $tmp1 = Fay$$_($p1);
        if ($tmp1 instanceof Fay$$Cons) {
          var t = $tmp1.car;
          var ts = $tmp1.cdr;
          return Fay$$_(Fay$$_(Fay$$cons)(t))(Fay$$_(reorder)(ts));
        }
        if (Fay$$_($p1) === null) {
          return null;
        }
        throw ["unhandled case in reorder",[$p1]];
      });
    };
    var finalize = function($p1){
      return new Fay$$$(function(){
        if (Fay$$listLen(Fay$$_($p1),2)) {
          var ol = Fay$$index(0,Fay$$_($p1));
          if (Fay$$_(Fay$$index(1,Fay$$_($p1))) === null) {
            return ol;
          }
        }
        return Prelude.$_undefined;
      });
    };
    var ppp = function($p1){
      return new Fay$$$(function(){
        var $tmp1 = Fay$$_($p1);
        if ($tmp1 instanceof Fay$$Cons) {
          if (Fay$$_($tmp1.car) instanceof Outline._INDENT) {
            var $tmp2 = Fay$$_($tmp1.cdr);
            if ($tmp2 instanceof Fay$$Cons) {
              if (Fay$$_($tmp2.car) instanceof Outline._LINE) {
                var l = Fay$$_($tmp2.car).slot1;
                var ts = $tmp2.cdr;
                return (function($tmp1){
                  if (Fay$$listLen(Fay$$_($tmp1),2)) {
                    var subs = Fay$$index(0,Fay$$_($tmp1));
                    var r = Fay$$index(1,Fay$$_($tmp1));
                    return Fay$$list([Fay$$_(Fay$$_(Outline.OL)(l))(subs),r]);
                  }
                  return (function(){ throw (["unhandled case",$tmp1]); })();
                })(Fay$$_(Fay$$_(pseq)(null))(ts));
              }
            }
          }
        }
        var $tmp1 = Fay$$_($p1);
        if ($tmp1 instanceof Fay$$Cons) {
          if (Fay$$_($tmp1.car) instanceof Outline._LINE) {
            var l = Fay$$_($tmp1.car).slot1;
            var ts = $tmp1.cdr;
            return Fay$$list([Fay$$_(Fay$$_(Outline.OL)(l))(null),ts]);
          }
        }
        return Prelude.$_undefined;
      });
    };
    var pseq = function($p1){
      return function($p2){
        return new Fay$$$(function(){
          var $tmp1 = Fay$$_($p2);
          if ($tmp1 instanceof Fay$$Cons) {
            if (Fay$$_($tmp1.car) instanceof Outline._DEDENT) {
              var remain = $tmp1.cdr;
              var acc = $p1;
              return Fay$$list([Fay$$_(Prelude.reverse)(acc),remain]);
            }
          }
          var ts = $p2;
          var acc = $p1;
          return (function($tmp1){
            if (Fay$$listLen(Fay$$_($tmp1),2)) {
              var t = Fay$$index(0,Fay$$_($tmp1));
              var remain = Fay$$index(1,Fay$$_($tmp1));
              return Fay$$_(Fay$$_(pseq)(Fay$$_(Fay$$_(Fay$$cons)(t))(acc)))(remain);
            }
            return (function(){ throw (["unhandled case",$tmp1]); })();
          })(Fay$$_(ppp)(ts));
        });
      };
    };
    var ollex = function($p1){
      return new Fay$$$(function(){
        var s = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Fay$$_(getIndent)(null))(0))(0))(s);
      });
    };
    var getIndent = function($p1){
      return function($p2){
        return function($p3){
          return function($p4){
            return new Fay$$$(function(){
              var $tmp1 = Fay$$_($p4);
              if ($tmp1 instanceof Fay$$Cons) {
                if (Fay$$_($tmp1.car) === "\t") {
                  var cs = $tmp1.cdr;
                  var count = $p3;
                  var pr = $p2;
                  var acc = $p1;
                  return Fay$$_(Fay$$_(Fay$$_(Fay$$_(getIndent)(acc))(pr))(Fay$$_(Fay$$_(Fay$$add)(count))(1)))(cs);
                }
              }
              var cs = $p4;
              var count = $p3;
              var pr = $p2;
              var acc = $p1;
              return Fay$$_(Fay$$_(Fay$$_(Fay$$_(dent)(acc))(pr))(count))(cs);
            });
          };
        };
      };
    };
    var pgetText = function($p1){
      return function($p2){
        return function($p3){
          return function($p4){
            return new Fay$$$(function(){
              if (Fay$$_($p4) === null) {
                if (Fay$$_($p3) === null) {
                  var acc = $p1;
                  return Fay$$_(Prelude.reverse)(acc);
                }
              }
              if (Fay$$equal($p4,Fay$$list("\n"))) {
                if (Fay$$_($p3) === null) {
                  var acc = $p1;
                  return Fay$$_(Prelude.reverse)(acc);
                }
              }
              if (Fay$$_($p4) === null) {
                var str = $p3;
                var acc = $p1;
                return Fay$$_(Prelude.reverse)(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Prelude.$36$)(Outline.LINE))(Fay$$_(Fay$$_(Prelude.$36$)(Outline.ols))(Fay$$_(Prelude.reverse)(str)))))(acc));
              }
              var $tmp1 = Fay$$_($p4);
              if ($tmp1 instanceof Fay$$Cons) {
                if (Fay$$_($tmp1.car) === "\n") {
                  var cs = $tmp1.cdr;
                  var str = $p3;
                  var pr = $p2;
                  var acc = $p1;
                  return Fay$$_(Fay$$_(Fay$$_(Fay$$_(getIndent)(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Prelude.$36$)(Outline.LINE))(Fay$$_(Fay$$_(Prelude.$36$)(Outline.ols))(Fay$$_(Prelude.reverse)(str)))))(acc)))(pr))(0))(cs);
                }
              }
              var $tmp1 = Fay$$_($p4);
              if ($tmp1 instanceof Fay$$Cons) {
                var c = $tmp1.car;
                var cs = $tmp1.cdr;
                var str = $p3;
                var pr = $p2;
                var acc = $p1;
                return Fay$$_(Fay$$_(Fay$$_(Fay$$_(pgetText)(acc))(pr))(Fay$$_(Fay$$_(Fay$$cons)(c))(str)))(cs);
              }
              throw ["unhandled case in pgetText",[$p1,$p2,$p3,$p4]];
            });
          };
        };
      };
    };
    var overdent = new Fay$$$(function(){
      return Fay$$list("too much indentation");
    });
    var dent = function($p1){
      return function($p2){
        return function($p3){
          return function($p4){
            return new Fay$$$(function(){
              var cs = $p4;
              var n = $p3;
              var o = $p2;
              var acc = $p1;
              return (function($tmp1){
                if (Fay$$_($tmp1) instanceof Prelude._GT) {
                  return Fay$$_(Fay$$_(Fay$$_(Fay$$neq)(Fay$$_(Fay$$_(Fay$$add)(o))(1)))(n)) ? Fay$$_(Prelude.error)(overdent) : Fay$$_(Fay$$_(Fay$$_(Fay$$_(pgetText)(Fay$$_(Fay$$_(Fay$$cons)(Outline.INDENT))(acc)))(n))(Fay$$list("")))(cs);
                }
                if (Fay$$_($tmp1) instanceof Prelude._LT) {
                  return Fay$$_(Fay$$_(Fay$$_(Fay$$_(dent)(Fay$$_(Fay$$_(Fay$$cons)(Outline.DEDENT))(acc)))(Fay$$_(Fay$$_(Fay$$sub)(o))(1)))(n))(cs);
                }
                if (Fay$$_($tmp1) instanceof Prelude._EQ) {
                  return Fay$$_(Fay$$_(Fay$$_(Fay$$_(pgetText)(acc))(n))(Fay$$list("")))(cs);
                }
                return (function(){ throw (["unhandled case",$tmp1]); })();
              })(Fay$$_(Fay$$_(Prelude.compare)(n))(o));
            });
          };
        };
      };
    };
    return Fay$$_(Fay$$_(Prelude.$46$)(finalize))(Fay$$_(Fay$$_(Prelude.$46$)(ppp))(Fay$$_(Fay$$_(Prelude.$46$)(reorder))(ollex)));
  });
});
Outline.isChildOf = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var child = $p2;
      var parent = $p1;
      return (function(){
        var arr = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              if (Fay$$_($p1) === null) {
                return Prelude.Nothing;
              }
              if (Fay$$_($p2) === null) {
                if (Fay$$listLen(Fay$$_($p1),1)) {
                  var i = Fay$$index(0,Fay$$_($p1));
                  return Fay$$_(Prelude.Just)(i);
                }
                return Prelude.Nothing;
              }
              var $tmp1 = Fay$$_($p2);
              if ($tmp1 instanceof Fay$$Cons) {
                var b = $tmp1.car;
                var bs = $tmp1.cdr;
                var $tmp1 = Fay$$_($p1);
                if ($tmp1 instanceof Fay$$Cons) {
                  var a = $tmp1.car;
                  var as = $tmp1.cdr;
                  return Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(a))(b)) ? Fay$$_(Fay$$_(arr)(as))(bs) : Prelude.Nothing;
                }
              }
              throw ["unhandled case in arr",[$p1,$p2]];
            });
          };
        };
        return Fay$$_(Fay$$_(arr)(Fay$$_(Prelude.reverse)(parent)))(Fay$$_(Prelude.reverse)(child));
      })();
    });
  };
};
Fay$$objConcat(Fay$$fayToJsHash,{"Addr": function(type,argTypes,_obj){
  var obj_ = {"instance": "Addr"};
  var obj_slot1 = Fay$$fayToJs(["list",[["int"]]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"OLStr": function(type,argTypes,_obj){
  var obj_ = {"instance": "OLStr"};
  var obj_slot1 = Fay$$fayToJs_string(_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"OL": function(type,argTypes,_obj){
  var obj_ = {"instance": "OL"};
  var obj_slot1 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  var obj_slot2 = Fay$$fayToJs(["list",[["user","Outline",[]]]],_obj.slot2);
  if (undefined !== obj_slot2) {
    obj_['slot2'] = obj_slot2;
  }
  return obj_;
},"INDENT": function(type,argTypes,_obj){
  var obj_ = {"instance": "INDENT"};
  return obj_;
},"DEDENT": function(type,argTypes,_obj){
  var obj_ = {"instance": "DEDENT"};
  return obj_;
},"LINE": function(type,argTypes,_obj){
  var obj_ = {"instance": "LINE"};
  var obj_slot1 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"Addr": function(type,argTypes,obj){
  return new Outline._Addr(Fay$$jsToFay(["list",[["int"]]],obj["slot1"]));
},"OLStr": function(type,argTypes,obj){
  return new Outline._OLStr(Fay$$jsToFay_string(obj["slot1"]));
},"OL": function(type,argTypes,obj){
  return new Outline._OL(Fay$$jsToFay(["user","OLStr",[]],obj["slot1"]),Fay$$jsToFay(["list",[["user","Outline",[]]]],obj["slot2"]));
},"INDENT": function(type,argTypes,obj){
  return new Outline._INDENT();
},"DEDENT": function(type,argTypes,obj){
  return new Outline._DEDENT();
},"LINE": function(type,argTypes,obj){
  return new Outline._LINE(Fay$$jsToFay(["user","OLStr",[]],obj["slot1"]));
}});
var Edit = {};
Edit._ADD = function ADD(slot1,slot2){
  this.slot1 = slot1;
  this.slot2 = slot2;
};
Edit._ADD.prototype.instance = "ADD";
Edit.ADD = function(slot1){
  return function(slot2){
    return new Fay$$$(function(){
      return new Edit._ADD(slot1,slot2);
    });
  };
};
Edit._RPL = function RPL(slot1,slot2){
  this.slot1 = slot1;
  this.slot2 = slot2;
};
Edit._RPL.prototype.instance = "RPL";
Edit.RPL = function(slot1){
  return function(slot2){
    return new Fay$$$(function(){
      return new Edit._RPL(slot1,slot2);
    });
  };
};
Edit._DEL = function DEL(slot1){
  this.slot1 = slot1;
};
Edit._DEL.prototype.instance = "DEL";
Edit.DEL = function(slot1){
  return new Fay$$$(function(){
    return new Edit._DEL(slot1);
  });
};
Edit._EDT = function EDT(slot1,slot2){
  this.slot1 = slot1;
  this.slot2 = slot2;
};
Edit._EDT.prototype.instance = "EDT";
Edit.EDT = function(slot1){
  return function(slot2){
    return new Fay$$$(function(){
      return new Edit._EDT(slot1,slot2);
    });
  };
};
Edit.edit = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var e = $p2;
      var o = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Edit.opOkay)(o))(e)) ? Fay$$_(Prelude.Just)(Fay$$list([Fay$$_(Fay$$_(Edit.mutate)(o))(e),Fay$$_(Fay$$_(Edit.undo)(o))(e)])) : Prelude.Nothing;
    });
  };
};
Edit.edit$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var e = $p2;
      var o = $p1;
      return (function($tmp1){
        if (Fay$$_($tmp1) instanceof Prelude._Just) {
          var r = Fay$$_($tmp1).slot1;
          return r;
        }
        if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Prelude.error))(Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$list("Invalid edit: (")))(Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(Prelude.show)(e)))(Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$list(") on (")))(Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(Prelude.show)(o)))(Fay$$list(")."))))));
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(Fay$$_(Fay$$_(Edit.edit)(o))(e));
    });
  };
};
Edit.edits = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var es = $p2;
      var outline = $p1;
      return (function(){
        var r = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              if (Fay$$_($p1) instanceof Prelude._Nothing) {
                return Prelude.Nothing;
              }
              var e = $p2;
              if (Fay$$_($p1) instanceof Prelude._Just) {
                if (Fay$$listLen(Fay$$_(Fay$$_($p1).slot1),2)) {
                  var o = Fay$$index(0,Fay$$_(Fay$$_($p1).slot1));
                  var undos = Fay$$index(1,Fay$$_(Fay$$_($p1).slot1));
                  return (function($tmp1){
                    if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
                      return Prelude.Nothing;
                    }
                    if (Fay$$_($tmp1) instanceof Prelude._Just) {
                      if (Fay$$listLen(Fay$$_(Fay$$_($tmp1).slot1),2)) {
                        var o$39$ = Fay$$index(0,Fay$$_(Fay$$_($tmp1).slot1));
                        var undoOp = Fay$$index(1,Fay$$_(Fay$$_($tmp1).slot1));
                        return Fay$$_(Prelude.Just)(Fay$$list([o$39$,Fay$$_(Fay$$_(Fay$$cons)(undoOp))(undos)]));
                      }
                    }
                    return (function(){ throw (["unhandled case",$tmp1]); })();
                  })(Fay$$_(Fay$$_(Edit.edit)(o))(e));
                }
              }
              throw ["unhandled case in r",[$p1,$p2]];
            });
          };
        };
        return Fay$$_(Fay$$_(Fay$$_(Prelude.foldl)(r))(Fay$$_(Prelude.Just)(Fay$$list([outline,null]))))(es);
      })();
    });
  };
};
Edit.bad = new Fay$$$(function(){
  return Fay$$_(Prelude.error)(Fay$$list("Something went terribly wrong in Edit.hs"));
});
Edit.linsert = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var e = $p3;
        if (Fay$$_($p2) === 0) {
          var l = $p1;
          return Fay$$_(Fay$$_(Fay$$cons)(e))(l);
        }
        if (Fay$$_($p1) === null) {
          return Edit.bad;
        }
        var e = $p3;
        var n = $p2;
        var $tmp1 = Fay$$_($p1);
        if ($tmp1 instanceof Fay$$Cons) {
          var a = $tmp1.car;
          var as = $tmp1.cdr;
          return Fay$$_(Fay$$_(Fay$$cons)(a))(Fay$$_(Fay$$_(Fay$$_(Edit.linsert)(as))(Fay$$_(Fay$$_(Fay$$sub)(n))(1)))(e));
        }
        throw ["unhandled case in linsert",[$p1,$p2,$p3]];
      });
    };
  };
};
Edit.canAddHere = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p1) instanceof Outline._Addr) {
        if (Fay$$_(Fay$$_($p1).slot1) === null) {
          return false;
        }
      }
      var ol = $p2;
      var a = $p1;
      if (Fay$$_($p1) instanceof Outline._Addr) {
        var $tmp1 = Fay$$_(Fay$$_($p1).slot1);
        if ($tmp1 instanceof Fay$$Cons) {
          if (Fay$$_($tmp1.car) === 0) {
            return Fay$$_(Fay$$_(Outline.addrOk)(Fay$$_(Outline.addrParent)(a)))(ol);
          }
        }
      }
      var ol = $p2;
      if (Fay$$_($p1) instanceof Outline._Addr) {
        var $tmp1 = Fay$$_(Fay$$_($p1).slot1);
        if ($tmp1 instanceof Fay$$Cons) {
          var i = $tmp1.car;
          var is = $tmp1.cdr;
          return Fay$$_(Fay$$_(Outline.addrOk)(Fay$$_(Outline.Addr)(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Fay$$sub)(i))(1)))(is))))(ol);
        }
      }
      throw ["unhandled case in canAddHere",[$p1,$p2]];
    });
  };
};
Edit.opOkay = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) instanceof Edit._ADD) {
        var a = Fay$$_($p2).slot1;
        var ol = $p1;
        return Fay$$_(Fay$$_(Edit.canAddHere)(a))(ol);
      }
      if (Fay$$_($p2) instanceof Edit._RPL) {
        var a = Fay$$_($p2).slot1;
        var ol = $p1;
        return Fay$$_(Fay$$_(Outline.addrOk)(a))(ol);
      }
      if (Fay$$_($p2) instanceof Edit._DEL) {
        var a = Fay$$_($p2).slot1;
        var ol = $p1;
        return Fay$$_(Fay$$_(Outline.addrOk)(a))(ol);
      }
      if (Fay$$_($p2) instanceof Edit._EDT) {
        var a = Fay$$_($p2).slot1;
        var ol = $p1;
        return Fay$$_(Fay$$_(Outline.addrOk)(a))(ol);
      }
      throw ["unhandled case in opOkay",[$p1,$p2]];
    });
  };
};
Edit.getFrag = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var o = $p2;
      var a = $p1;
      return (function($tmp1){
        if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
          return Edit.bad;
        }
        if (Fay$$_($tmp1) instanceof Prelude._Just) {
          var f = Fay$$_($tmp1).slot1;
          return f;
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(Fay$$_(Fay$$_(Outline.olget)(a))(o));
    });
  };
};
Edit.undo = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var pedit = $p2;
      var outline = $p1;
      return (function($tmp1){
        if (Fay$$_($tmp1) instanceof Edit._RPL) {
          var a = Fay$$_($tmp1).slot1;
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Edit.RPL)(a)))(Fay$$_(Fay$$_(Edit.getFrag)(a))(outline));
        }
        if (Fay$$_($tmp1) instanceof Edit._DEL) {
          if (Fay$$_(Fay$$_($tmp1).slot1) instanceof Outline._Addr) {
            if (Fay$$_(Fay$$_(Fay$$_($tmp1).slot1).slot1) === null) {
              return Fay$$_(Fay$$_(Edit.RPL)(Fay$$_(Outline.Addr)(null)))(outline);
            }
          }
          var a = Fay$$_($tmp1).slot1;
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Edit.ADD)(a)))(Fay$$_(Fay$$_(Edit.getFrag)(a))(outline));
        }
        if (Fay$$_($tmp1) instanceof Edit._ADD) {
          var a = Fay$$_($tmp1).slot1;
          return Fay$$_(Edit.DEL)(a);
        }
        if (Fay$$_($tmp1) instanceof Edit._EDT) {
          var a = Fay$$_($tmp1).slot1;
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Edit.EDT)(a)))(Fay$$_(Fay$$_(Prelude.$36$)(Outline.ols))(Fay$$_(Fay$$_(Prelude.$36$)(Outline.oltext))(Fay$$_(Fay$$_(Edit.getFrag)(a))(outline))));
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(pedit);
    });
  };
};
Edit.mutate = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var operation = $p2;
      var outline = $p1;
      return (function($tmp1){
        if (Fay$$_($tmp1) instanceof Edit._DEL) {
          var delAt = Fay$$_($tmp1).slot1;
          return Fay$$_(Fay$$_(Edit.del)(outline))(delAt);
        }
        if (Fay$$_($tmp1) instanceof Edit._ADD) {
          var addAt = Fay$$_($tmp1).slot1;
          var frag = Fay$$_($tmp1).slot2;
          return Fay$$_(Fay$$_(Fay$$_(Edit.add)(outline))(addAt))(frag);
        }
        if (Fay$$_($tmp1) instanceof Edit._RPL) {
          var rplAt = Fay$$_($tmp1).slot1;
          var frag = Fay$$_($tmp1).slot2;
          return Fay$$_(Fay$$_(Fay$$_(Edit.rpl)(outline))(rplAt))(frag);
        }
        if (Fay$$_($tmp1) instanceof Edit._EDT) {
          var a = Fay$$_($tmp1).slot1;
          var t = Fay$$_($tmp1).slot2;
          return Fay$$_(Fay$$_(Fay$$_(Edit.edt)(outline))(a))(t);
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(operation);
    });
  };
};
Edit.edt = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var txt = $p3;
        var at = $p2;
        var o = $p1;
        return (function(){
          var f = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                var a = $p1;
                return Fay$$_(Fay$$_(Fay$$_(Fay$$neq)(a))(at)) ? Util.Descend : (function($tmp1){
                  if (Fay$$_($tmp1) instanceof Outline._OL) {
                    var oldchilds = Fay$$_($tmp1).slot2;
                    return Fay$$_(Fay$$_(Prelude.$36$)(Util.Replace))(Fay$$_(Fay$$_(Outline.OL)(txt))(oldchilds));
                  }
                  return (function(){ throw (["unhandled case",$tmp1]); })();
                })(Fay$$_(Fay$$_(Edit.getFrag)(at))(o));
              });
            };
          };
          return Fay$$_(Fay$$_(Outline.olwalk)(f))(o);
        })();
      });
    };
  };
};
Edit.del = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var delAt = $p2;
      var outline = $p1;
      return (function(){
        var f = function($p1){
          return function($p2){
            return new Fay$$$(function(){
              var a = $p1;
              return Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(a))(delAt)) ? Util.DeleteSubtree : Util.Descend;
            });
          };
        };
        return Fay$$_(Fay$$_(Outline.olwalk)(f))(outline);
      })();
    });
  };
};
Edit.rpl = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var frag = $p3;
        var replaceAt = $p2;
        var outline = $p1;
        return (function(){
          var f = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                var a = $p1;
                return Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(a))(replaceAt)) ? Fay$$_(Util.Replace)(frag) : Util.Descend;
              });
            };
          };
          return Fay$$_(Fay$$_(Outline.olwalk)(f))(outline);
        })();
      });
    };
  };
};
Edit.add = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        if (Fay$$_($p2) instanceof Outline._Addr) {
          if (Fay$$_(Fay$$_($p2).slot1) === null) {
            return Edit.bad;
          }
        }
        var frag = $p3;
        if (Fay$$_($p2) instanceof Outline._Addr) {
          var addAt = Fay$$_($p2).slot1;
          var outline = $p1;
          return (function(){
            var f = function($p1){
              return function($p2){
                return new Fay$$$(function(){
                  if (Fay$$_($p2) instanceof Outline._OL) {
                    var s = Fay$$_($p2).slot1;
                    var childs = Fay$$_($p2).slot2;
                    if (Fay$$_($p1) instanceof Outline._Addr) {
                      var a = Fay$$_($p1).slot1;
                      return (function($tmp1){
                        if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
                          return Util.Descend;
                        }
                        if (Fay$$_($tmp1) instanceof Prelude._Just) {
                          var idx = Fay$$_($tmp1).slot1;
                          return Fay$$_(Fay$$_(Prelude.$36$)(Util.Replace))(Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Outline.OL)(s)))(Fay$$_(Fay$$_(Fay$$_(Edit.linsert)(childs))(idx))(frag)));
                        }
                        return (function(){ throw (["unhandled case",$tmp1]); })();
                      })(Fay$$_(Fay$$_(Outline.isChildOf)(addAt))(a));
                    }
                  }
                  throw ["unhandled case in f",[$p1,$p2]];
                });
              };
            };
            return Fay$$_(Fay$$_(Outline.olwalk)(f))(outline);
          })();
        }
        throw ["unhandled case in add",[$p1,$p2,$p3]];
      });
    };
  };
};
Fay$$objConcat(Fay$$fayToJsHash,{"ADD": function(type,argTypes,_obj){
  var obj_ = {"instance": "ADD"};
  var obj_slot1 = Fay$$fayToJs(["user","Addr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  var obj_slot2 = Fay$$fayToJs(["user","Outline",[]],_obj.slot2);
  if (undefined !== obj_slot2) {
    obj_['slot2'] = obj_slot2;
  }
  return obj_;
},"RPL": function(type,argTypes,_obj){
  var obj_ = {"instance": "RPL"};
  var obj_slot1 = Fay$$fayToJs(["user","Addr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  var obj_slot2 = Fay$$fayToJs(["user","Outline",[]],_obj.slot2);
  if (undefined !== obj_slot2) {
    obj_['slot2'] = obj_slot2;
  }
  return obj_;
},"DEL": function(type,argTypes,_obj){
  var obj_ = {"instance": "DEL"};
  var obj_slot1 = Fay$$fayToJs(["user","Addr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"EDT": function(type,argTypes,_obj){
  var obj_ = {"instance": "EDT"};
  var obj_slot1 = Fay$$fayToJs(["user","Addr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  var obj_slot2 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot2);
  if (undefined !== obj_slot2) {
    obj_['slot2'] = obj_slot2;
  }
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"ADD": function(type,argTypes,obj){
  return new Edit._ADD(Fay$$jsToFay(["user","Addr",[]],obj["slot1"]),Fay$$jsToFay(["user","Outline",[]],obj["slot2"]));
},"RPL": function(type,argTypes,obj){
  return new Edit._RPL(Fay$$jsToFay(["user","Addr",[]],obj["slot1"]),Fay$$jsToFay(["user","Outline",[]],obj["slot2"]));
},"DEL": function(type,argTypes,obj){
  return new Edit._DEL(Fay$$jsToFay(["user","Addr",[]],obj["slot1"]));
},"EDT": function(type,argTypes,obj){
  return new Edit._EDT(Fay$$jsToFay(["user","Addr",[]],obj["slot1"]),Fay$$jsToFay(["user","OLStr",[]],obj["slot2"]));
}});
var Editor = {};
Editor._State = function State(stSel,stOL,stUndos,stClip){
  this.stSel = stSel;
  this.stOL = stOL;
  this.stUndos = stUndos;
  this.stClip = stClip;
};
Editor._State.prototype.instance = "State";
Editor.State = function(stSel){
  return function(stOL){
    return function(stUndos){
      return function(stClip){
        return new Fay$$$(function(){
          return new Editor._State(stSel,stOL,stUndos,stClip);
        });
      };
    };
  };
};
Editor.stSel = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).stSel;
  });
};
Editor.stOL = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).stOL;
  });
};
Editor.stUndos = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).stUndos;
  });
};
Editor.stClip = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).stClip;
  });
};
Editor.mkeditor = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var o = $p2;
      var a = $p1;
      return Fay$$_(Fay$$_(Fay$$_(Fay$$_(Editor.State)(a))(o))(null))(Prelude.Nothing);
    });
  };
};
Editor._SelDown = function SelDown(){
};
Editor._SelDown.prototype.instance = "SelDown";
Editor.SelDown = new Fay$$$(function(){
  return new Editor._SelDown();
});
Editor._SelLeft = function SelLeft(){
};
Editor._SelLeft.prototype.instance = "SelLeft";
Editor.SelLeft = new Fay$$$(function(){
  return new Editor._SelLeft();
});
Editor._SelUp = function SelUp(){
};
Editor._SelUp.prototype.instance = "SelUp";
Editor.SelUp = new Fay$$$(function(){
  return new Editor._SelUp();
});
Editor._SelRight = function SelRight(){
};
Editor._SelRight.prototype.instance = "SelRight";
Editor.SelRight = new Fay$$$(function(){
  return new Editor._SelRight();
});
Editor._Select = function Select(slot1){
  this.slot1 = slot1;
};
Editor._Select.prototype.instance = "Select";
Editor.Select = function(slot1){
  return new Fay$$$(function(){
    return new Editor._Select(slot1);
  });
};
Editor._ReplaceTxt = function ReplaceTxt(slot1){
  this.slot1 = slot1;
};
Editor._ReplaceTxt.prototype.instance = "ReplaceTxt";
Editor.ReplaceTxt = function(slot1){
  return new Fay$$$(function(){
    return new Editor._ReplaceTxt(slot1);
  });
};
Editor._Delete = function Delete(){
};
Editor._Delete.prototype.instance = "Delete";
Editor.Delete = new Fay$$$(function(){
  return new Editor._Delete();
});
Editor._Nada = function Nada(){
};
Editor._Nada.prototype.instance = "Nada";
Editor.Nada = new Fay$$$(function(){
  return new Editor._Nada();
});
Editor._InsBefore = function InsBefore(slot1){
  this.slot1 = slot1;
};
Editor._InsBefore.prototype.instance = "InsBefore";
Editor.InsBefore = function(slot1){
  return new Fay$$$(function(){
    return new Editor._InsBefore(slot1);
  });
};
Editor._InsAfter = function InsAfter(slot1){
  this.slot1 = slot1;
};
Editor._InsAfter.prototype.instance = "InsAfter";
Editor.InsAfter = function(slot1){
  return new Fay$$$(function(){
    return new Editor._InsAfter(slot1);
  });
};
Editor._InsAbove = function InsAbove(slot1){
  this.slot1 = slot1;
};
Editor._InsAbove.prototype.instance = "InsAbove";
Editor.InsAbove = function(slot1){
  return new Fay$$$(function(){
    return new Editor._InsAbove(slot1);
  });
};
Editor._InsBelow = function InsBelow(slot1){
  this.slot1 = slot1;
};
Editor._InsBelow.prototype.instance = "InsBelow";
Editor.InsBelow = function(slot1){
  return new Fay$$$(function(){
    return new Editor._InsBelow(slot1);
  });
};
Editor._Undo = function Undo(){
};
Editor._Undo.prototype.instance = "Undo";
Editor.Undo = new Fay$$$(function(){
  return new Editor._Undo();
});
Editor._Copy = function Copy(){
};
Editor._Copy.prototype.instance = "Copy";
Editor.Copy = new Fay$$$(function(){
  return new Editor._Copy();
});
Editor._Cut = function Cut(){
};
Editor._Cut.prototype.instance = "Cut";
Editor.Cut = new Fay$$$(function(){
  return new Editor._Cut();
});
Editor._PasteBefore = function PasteBefore(){
};
Editor._PasteBefore.prototype.instance = "PasteBefore";
Editor.PasteBefore = new Fay$$$(function(){
  return new Editor._PasteBefore();
});
Editor._PasteAfter = function PasteAfter(){
};
Editor._PasteAfter.prototype.instance = "PasteAfter";
Editor.PasteAfter = new Fay$$$(function(){
  return new Editor._PasteAfter();
});
Editor.fudgeAddr = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Editor._State) {
      if (Fay$$_(Fay$$_($p1).stSel) instanceof Outline._Addr) {
        var addr = Fay$$_(Fay$$_($p1).stSel).slot1;
        var ol = Fay$$_($p1).stOL;
        var undos = Fay$$_($p1).stUndos;
        var c = Fay$$_($p1).stClip;
        return (function(){
          var fudge = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                if (Fay$$_($p1) === null) {
                  return null;
                }
                if (Fay$$_($p2) instanceof Outline._OL) {
                  if (Fay$$_(Fay$$_($p2).slot2) === null) {
                    return null;
                  }
                  var s = Fay$$_($p2).slot1;
                  var sub = Fay$$_($p2).slot2;
                  var $tmp1 = Fay$$_($p1);
                  if ($tmp1 instanceof Fay$$Cons) {
                    var a = $tmp1.car;
                    var as = $tmp1.cdr;
                    return Fay$$_(Fay$$_(Fay$$_(Fay$$lt)(a))(0)) ? Fay$$_(Fay$$_(fudge)(Fay$$_(Fay$$_(Fay$$cons)(0))(as)))(Fay$$_(Fay$$_(Outline.OL)(s))(sub)) : Fay$$_(Fay$$_(Fay$$_(Fay$$gte)(a))(Fay$$_(Prelude.length)(sub))) ? Fay$$_(Fay$$_(fudge)(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Fay$$sub)(a))(1)))(as)))(Fay$$_(Fay$$_(Outline.OL)(s))(sub)) : Fay$$_(Fay$$_(Fay$$cons)(a))(Fay$$_(Fay$$_(fudge)(as))(Fay$$_(Fay$$_(Prelude.$33$$33$)(sub))(a)));
                  }
                }
                throw ["unhandled case in fudge",[$p1,$p2]];
              });
            };
          };
          return Fay$$_(Fay$$_(Fay$$_(Fay$$_(Editor.State)(Fay$$_(Fay$$_(Prelude.$36$)(Outline.Addr))(Fay$$_(Fay$$_(Prelude.$36$)(Prelude.reverse))(Fay$$_(Fay$$_(fudge)(Fay$$_(Prelude.reverse)(addr)))(ol)))))(ol))(undos))(c);
        })();
      }
    }
    throw ["unhandled case in fudgeAddr",[$p1]];
  });
};
Editor.down = new Fay$$$(function(){
  return Outline.addrAfter;
});
Editor.left = new Fay$$$(function(){
  return Outline.addrParent;
});
Editor.right = new Fay$$$(function(){
  return Outline.addrChild;
});
Editor.up = new Fay$$$(function(){
  return Outline.addrBefore;
});
Editor.moveAddr = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) instanceof Editor._State) {
        var a = Fay$$_($p2).stSel;
        var o = Fay$$_($p2).stOL;
        var a$39$ = $p1;
        return Fay$$_(Fay$$_(Fay$$_(Outline.addrOk)(a$39$))(o)) ? a$39$ : a;
      }
      throw ["unhandled case in moveAddr",[$p1,$p2]];
    });
  };
};
Editor.doundo = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Editor._State) {
      var o = Fay$$_($p1).stOL;
      var u = Fay$$_($p1).stUndos;
      var c = Fay$$_($p1).stClip;
      return (function($tmp1){
        if (Fay$$_($tmp1) === null) {
          return Prelude.Nothing;
        }
        var $tmp2 = Fay$$_($tmp1);
        if ($tmp2 instanceof Fay$$Cons) {
          if (Fay$$listLen(Fay$$_($tmp2.car),2)) {
            var a$39$ = Fay$$index(0,Fay$$_($tmp2.car));
            var ops = Fay$$index(1,Fay$$_($tmp2.car));
            var m = $tmp2.cdr;
            return (function($tmp2){
              if (Fay$$_($tmp2) instanceof Prelude._Nothing) {
                return Prelude.Nothing;
              }
              if (Fay$$_($tmp2) instanceof Prelude._Just) {
                if (Fay$$listLen(Fay$$_(Fay$$_($tmp2).slot1),2)) {
                  var o$39$ = Fay$$index(0,Fay$$_(Fay$$_($tmp2).slot1));
                  return Fay$$_(Fay$$_(Prelude.$36$)(Prelude.Just))(Fay$$_(Fay$$_(Fay$$_(Fay$$_(Editor.State)(a$39$))(o$39$))(m))(c));
                }
              }
              return (function(){ throw (["unhandled case",$tmp2]); })();
            })(Fay$$_(Fay$$_(Edit.edits)(o))(ops));
          }
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(u);
    }
    throw ["unhandled case in doundo",[$p1]];
  });
};
Editor.dropNOPs = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof Editor._State) {
      var a = Fay$$_($p1).stSel;
      var o = Fay$$_($p1).stOL;
      if (Fay$$_(Fay$$_($p1).stUndos) === null) {
        var c = Fay$$_($p1).stClip;
        return Fay$$_(Fay$$_(Fay$$_(Fay$$_(Editor.State)(a))(o))(null))(c);
      }
      var a = Fay$$_($p1).stSel;
      var o = Fay$$_($p1).stOL;
      var $tmp1 = Fay$$_(Fay$$_($p1).stUndos);
      if ($tmp1 instanceof Fay$$Cons) {
        if (Fay$$listLen(Fay$$_($tmp1.car),2)) {
          if (Fay$$_(Fay$$index(1,Fay$$_($tmp1.car))) === null) {
            var more = $tmp1.cdr;
            var c = Fay$$_($p1).stClip;
            return Fay$$_(Fay$$_(Prelude.$36$)(Editor.dropNOPs))(Fay$$_(Fay$$_(Fay$$_(Fay$$_(Editor.State)(a))(o))(more))(c));
          }
        }
      }
    }
    var s = $p1;
    return s;
  });
};
Editor.apply = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var s = $p2;
      var o = $p1;
      return (function($tmp1){
        if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
          return s;
        }
        if (Fay$$_($tmp1) instanceof Prelude._Just) {
          var s$39$ = Fay$$_($tmp1).slot1;
          return s$39$;
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(Fay$$_(Fay$$_(Editor.apply$39$)(o))(s));
    });
  };
};
Editor.apply$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var s = $p2;
      if (Fay$$_($p1) instanceof Editor._Undo) {
        return Fay$$_(Editor.doundo)(s);
      }
      if (Fay$$_($p2) instanceof Editor._State) {
        var a = Fay$$_($p2).stSel;
        var o = Fay$$_($p2).stOL;
        var u = Fay$$_($p2).stUndos;
        if (Fay$$_($p1) instanceof Editor._Copy) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Prelude.Just))(Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Fay$$_(Fay$$_(Editor.State)(a))(o))(u)))(Fay$$_(Fay$$_(Outline.olget)(a))(o)));
        }
      }
      var s = $p2;
      if (Fay$$_($p1) instanceof Editor._Cut) {
        return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Editor.apply$39$)(Editor.Delete)))(Fay$$_(Fay$$_(Prelude.$36$)(Util.fromJust))(Fay$$_(Fay$$_(Editor.apply$39$)(Editor.Copy))(s)));
      }
      var s = $p2;
      if (Fay$$_($p2) instanceof Editor._State) {
        var a = Fay$$_($p2).stSel;
        var ol = Fay$$_($p2).stOL;
        var u = Fay$$_($p2).stUndos;
        var c = Fay$$_($p2).stClip;
        var op = $p1;
        return (function($tmp1){
          if (Fay$$listLen(Fay$$_($tmp1),2)) {
            var a$39$ = Fay$$index(0,Fay$$_($tmp1));
            var es = Fay$$index(1,Fay$$_($tmp1));
            return (function($tmp2){
              if (Fay$$_($tmp2) instanceof Prelude._Nothing) {
                return Prelude.Nothing;
              }
              if (Fay$$_($tmp2) instanceof Prelude._Just) {
                if (Fay$$listLen(Fay$$_(Fay$$_($tmp2).slot1),2)) {
                  var ol$39$ = Fay$$index(0,Fay$$_(Fay$$_($tmp2).slot1));
                  var esMirror = Fay$$index(1,Fay$$_(Fay$$_($tmp2).slot1));
                  return Fay$$_(Fay$$_(Prelude.$36$)(Prelude.Just))(Fay$$_(Fay$$_(Prelude.$36$)(Editor.dropNOPs))(Fay$$_(Fay$$_(Prelude.$36$)(Editor.fudgeAddr))(Fay$$_(Fay$$_(Fay$$_(Fay$$_(Editor.State)(a$39$))(ol$39$))(Fay$$_(Fay$$_(Fay$$cons)(Fay$$list([a,esMirror])))(u)))(c))));
                }
              }
              return (function(){ throw (["unhandled case",$tmp2]); })();
            })(Fay$$_(Fay$$_(Edit.edits)(ol))(es));
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(Fay$$_(Fay$$_(Editor.compile)(op))(s));
      }
      throw ["unhandled case in apply'",[$p1,$p2]];
    });
  };
};
Editor.compile = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var s = $p2;
      if (Fay$$_($p2) instanceof Editor._State) {
        var a = Fay$$_($p2).stSel;
        var o = Fay$$_($p2).stOL;
        var c = Fay$$_($p2).stClip;
        var op = $p1;
        return (function($tmp1){
          if (Fay$$_($tmp1) instanceof Editor._Nada) {
            return Fay$$list([a,null]);
          }
          if (Fay$$_($tmp1) instanceof Editor._Select) {
            var a$39$ = Fay$$_($tmp1).slot1;
            return Fay$$list([Fay$$_(Fay$$_(Editor.moveAddr)(a$39$))(s),null]);
          }
          if (Fay$$_($tmp1) instanceof Editor._SelDown) {
            return Fay$$list([Fay$$_(Fay$$_(Editor.moveAddr)(Fay$$_(Editor.down)(a)))(s),null]);
          }
          if (Fay$$_($tmp1) instanceof Editor._SelUp) {
            return Fay$$list([Fay$$_(Fay$$_(Editor.moveAddr)(Fay$$_(Editor.up)(a)))(s),null]);
          }
          if (Fay$$_($tmp1) instanceof Editor._SelLeft) {
            return Fay$$list([Fay$$_(Fay$$_(Editor.moveAddr)(Fay$$_(Editor.left)(a)))(s),null]);
          }
          if (Fay$$_($tmp1) instanceof Editor._SelRight) {
            return Fay$$list([Fay$$_(Fay$$_(Editor.moveAddr)(Fay$$_(Editor.right)(a)))(s),null]);
          }
          if (Fay$$_($tmp1) instanceof Editor._Delete) {
            return Fay$$list([a,Fay$$list([Fay$$_(Edit.DEL)(a)])]);
          }
          if (Fay$$_($tmp1) instanceof Editor._ReplaceTxt) {
            var t = Fay$$_($tmp1).slot1;
            return Fay$$list([a,Fay$$list([Fay$$_(Fay$$_(Edit.EDT)(a))(t)])]);
          }
          if (Fay$$_($tmp1) instanceof Editor._InsBefore) {
            var t = Fay$$_($tmp1).slot1;
            return Fay$$list([a,Fay$$list([Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Edit.ADD)(a)))(Fay$$_(Fay$$_(Outline.OL)(t))(null))])]);
          }
          if (Fay$$_($tmp1) instanceof Editor._InsAfter) {
            var t = Fay$$_($tmp1).slot1;
            return Fay$$list([Fay$$_(Editor.down)(a),Fay$$list([Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Edit.ADD)(Fay$$_(Editor.down)(a))))(Fay$$_(Fay$$_(Outline.OL)(t))(null))])]);
          }
          if (Fay$$_($tmp1) instanceof Editor._InsBelow) {
            var t = Fay$$_($tmp1).slot1;
            return Fay$$list([Fay$$_(Editor.right)(a),Fay$$list([Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Edit.ADD)(Fay$$_(Editor.right)(a))))(Fay$$_(Fay$$_(Outline.OL)(t))(null))])]);
          }
          if (Fay$$_($tmp1) instanceof Editor._InsAbove) {
            var t = Fay$$_($tmp1).slot1;
            return Fay$$list([a,Fay$$list([Fay$$_(Edit.DEL)(a),Fay$$_(Fay$$_(Edit.ADD)(a))(Fay$$_(Fay$$_(Outline.OL)(t))(null)),Fay$$_(Fay$$_(Edit.ADD)(Fay$$_(Editor.right)(a)))(Fay$$_(Fay$$_(Prelude.$36$)(Util.fromJust))(Fay$$_(Fay$$_(Outline.olget)(a))(o)))])]);
          }
          if (Fay$$_($tmp1) instanceof Editor._PasteBefore) {
            return (function($tmp2){
              if (Fay$$_($tmp2) instanceof Prelude._Nothing) {
                return Fay$$list([a,null]);
              }
              if (Fay$$_($tmp2) instanceof Prelude._Just) {
                var f = Fay$$_($tmp2).slot1;
                return Fay$$list([a,Fay$$list([Fay$$_(Fay$$_(Edit.ADD)(a))(f)])]);
              }
              return (function(){ throw (["unhandled case",$tmp2]); })();
            })(c);
          }
          if (Fay$$_($tmp1) instanceof Editor._PasteAfter) {
            return (function($tmp2){
              if (Fay$$_($tmp2) instanceof Prelude._Nothing) {
                return Fay$$list([a,null]);
              }
              if (Fay$$_($tmp2) instanceof Prelude._Just) {
                var f = Fay$$_($tmp2).slot1;
                return Fay$$list([Fay$$_(Editor.down)(a),Fay$$list([Fay$$_(Fay$$_(Edit.ADD)(Fay$$_(Editor.down)(a)))(f)])]);
              }
              return (function(){ throw (["unhandled case",$tmp2]); })();
            })(c);
          }
          if (Fay$$_($tmp1) instanceof Editor._Cut) {
            return Fay$$_(Fay$$_(Editor.compile)(Editor.Delete))(s);
          }
          if (Fay$$_($tmp1) instanceof Editor._Copy) {
            return Prelude.$_undefined;
          }
          if (Fay$$_($tmp1) instanceof Editor._Undo) {
            return Prelude.$_undefined;
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(op);
      }
      throw ["unhandled case in compile",[$p1,$p2]];
    });
  };
};
Fay$$objConcat(Fay$$fayToJsHash,{"State": function(type,argTypes,_obj){
  var obj_ = {"instance": "State"};
  var obj_stSel = Fay$$fayToJs(["user","Addr",[]],_obj.stSel);
  if (undefined !== obj_stSel) {
    obj_['stSel'] = obj_stSel;
  }
  var obj_stOL = Fay$$fayToJs(["user","Outline",[]],_obj.stOL);
  if (undefined !== obj_stOL) {
    obj_['stOL'] = obj_stOL;
  }
  var obj_stUndos = Fay$$fayToJs(["list",[["tuple",[["user","Addr",[]],["list",[["user","Edit",[]]]]]]]],_obj.stUndos);
  if (undefined !== obj_stUndos) {
    obj_['stUndos'] = obj_stUndos;
  }
  var obj_stClip = Fay$$fayToJs(["user","Maybe",[["user","Outline",[]]]],_obj.stClip);
  if (undefined !== obj_stClip) {
    obj_['stClip'] = obj_stClip;
  }
  return obj_;
},"SelDown": function(type,argTypes,_obj){
  var obj_ = {"instance": "SelDown"};
  return obj_;
},"SelLeft": function(type,argTypes,_obj){
  var obj_ = {"instance": "SelLeft"};
  return obj_;
},"SelUp": function(type,argTypes,_obj){
  var obj_ = {"instance": "SelUp"};
  return obj_;
},"SelRight": function(type,argTypes,_obj){
  var obj_ = {"instance": "SelRight"};
  return obj_;
},"Select": function(type,argTypes,_obj){
  var obj_ = {"instance": "Select"};
  var obj_slot1 = Fay$$fayToJs(["user","Addr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"ReplaceTxt": function(type,argTypes,_obj){
  var obj_ = {"instance": "ReplaceTxt"};
  var obj_slot1 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"Delete": function(type,argTypes,_obj){
  var obj_ = {"instance": "Delete"};
  return obj_;
},"Nada": function(type,argTypes,_obj){
  var obj_ = {"instance": "Nada"};
  return obj_;
},"InsBefore": function(type,argTypes,_obj){
  var obj_ = {"instance": "InsBefore"};
  var obj_slot1 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"InsAfter": function(type,argTypes,_obj){
  var obj_ = {"instance": "InsAfter"};
  var obj_slot1 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"InsAbove": function(type,argTypes,_obj){
  var obj_ = {"instance": "InsAbove"};
  var obj_slot1 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"InsBelow": function(type,argTypes,_obj){
  var obj_ = {"instance": "InsBelow"};
  var obj_slot1 = Fay$$fayToJs(["user","OLStr",[]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"Undo": function(type,argTypes,_obj){
  var obj_ = {"instance": "Undo"};
  return obj_;
},"Copy": function(type,argTypes,_obj){
  var obj_ = {"instance": "Copy"};
  return obj_;
},"Cut": function(type,argTypes,_obj){
  var obj_ = {"instance": "Cut"};
  return obj_;
},"PasteBefore": function(type,argTypes,_obj){
  var obj_ = {"instance": "PasteBefore"};
  return obj_;
},"PasteAfter": function(type,argTypes,_obj){
  var obj_ = {"instance": "PasteAfter"};
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"State": function(type,argTypes,obj){
  return new Editor._State(Fay$$jsToFay(["user","Addr",[]],obj["stSel"]),Fay$$jsToFay(["user","Outline",[]],obj["stOL"]),Fay$$jsToFay(["list",[["tuple",[["user","Addr",[]],["list",[["user","Edit",[]]]]]]]],obj["stUndos"]),Fay$$jsToFay(["user","Maybe",[["user","Outline",[]]]],obj["stClip"]));
},"SelDown": function(type,argTypes,obj){
  return new Editor._SelDown();
},"SelLeft": function(type,argTypes,obj){
  return new Editor._SelLeft();
},"SelUp": function(type,argTypes,obj){
  return new Editor._SelUp();
},"SelRight": function(type,argTypes,obj){
  return new Editor._SelRight();
},"Select": function(type,argTypes,obj){
  return new Editor._Select(Fay$$jsToFay(["user","Addr",[]],obj["slot1"]));
},"ReplaceTxt": function(type,argTypes,obj){
  return new Editor._ReplaceTxt(Fay$$jsToFay(["user","OLStr",[]],obj["slot1"]));
},"Delete": function(type,argTypes,obj){
  return new Editor._Delete();
},"Nada": function(type,argTypes,obj){
  return new Editor._Nada();
},"InsBefore": function(type,argTypes,obj){
  return new Editor._InsBefore(Fay$$jsToFay(["user","OLStr",[]],obj["slot1"]));
},"InsAfter": function(type,argTypes,obj){
  return new Editor._InsAfter(Fay$$jsToFay(["user","OLStr",[]],obj["slot1"]));
},"InsAbove": function(type,argTypes,obj){
  return new Editor._InsAbove(Fay$$jsToFay(["user","OLStr",[]],obj["slot1"]));
},"InsBelow": function(type,argTypes,obj){
  return new Editor._InsBelow(Fay$$jsToFay(["user","OLStr",[]],obj["slot1"]));
},"Undo": function(type,argTypes,obj){
  return new Editor._Undo();
},"Copy": function(type,argTypes,obj){
  return new Editor._Copy();
},"Cut": function(type,argTypes,obj){
  return new Editor._Cut();
},"PasteBefore": function(type,argTypes,obj){
  return new Editor._PasteBefore();
},"PasteAfter": function(type,argTypes,obj){
  return new Editor._PasteAfter();
}});
var FayRef = {};
FayRef._FayRef = function FayRef(){
};
FayRef._FayRef.prototype.instance = "FayRef";
FayRef.FayRef = new Fay$$$(function(){
  return new FayRef._FayRef();
});
FayRef.newFayRef = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["user","FayRef",[["unknown"]]],{contents: Fay$$fayToJs(["unknown"],$p1)}));
  });
};
FayRef.readFayRef = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["unknown"],Fay$$fayToJs(["user","FayRef",[["unknown"]]],$p1)['contents']));
  });
};
FayRef.writeFayRef = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return new Fay$$Monad(Fay$$jsToFay(["unknown"],Fay$$fayToJs(["user","FayRef",[["unknown"]]],$p1)['contents']=Fay$$fayToJs(["unknown"],$p2)));
    });
  };
};
FayRef.modifyFayRef = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var f = $p2;
      var ref = $p1;
      return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(FayRef.readFayRef)(ref)))(Fay$$_(Fay$$_(Prelude.$46$)(Fay$$_(FayRef.writeFayRef)(ref)))(f));
    });
  };
};
FayRef.modifyFayRef$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var f = $p2;
      var ref = $p1;
      return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(FayRef.readFayRef)(ref)))(function($p1){
        var x = $p1;
        return (function(){
          return new Fay$$$(function(){
            var x$39$ = new Fay$$$(function(){
              return Fay$$_(f)(x);
            });
            return Fay$$_(Fay$$_(Prelude.$36$$33$)(Fay$$_(FayRef.writeFayRef)(ref)))(x$39$);
          });
        })();
      });
    });
  };
};
Fay$$objConcat(Fay$$fayToJsHash,{"FayRef": function(type,argTypes,_obj){
  var obj_ = {"instance": "FayRef"};
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"FayRef": function(type,argTypes,obj){
  return new FayRef._FayRef();
}});
var Sanitize = {};
Sanitize.sanitize = new Fay$$$(function(){
  return Fay$$_(Fay$$_(Prelude.$46$)(Sanitize.unlex))(Fay$$_(Fay$$_(Prelude.$46$)(Fay$$_(Sanitize.vblanks)(Sanitize.AUTO)))(Sanitize.tolex));
});
Sanitize._NONE = function NONE(){
};
Sanitize._NONE.prototype.instance = "NONE";
Sanitize.NONE = new Fay$$$(function(){
  return new Sanitize._NONE();
});
Sanitize._AUTO = function AUTO(){
};
Sanitize._AUTO.prototype.instance = "AUTO";
Sanitize.AUTO = new Fay$$$(function(){
  return new Sanitize._AUTO();
});
Sanitize._ONE = function ONE(){
};
Sanitize._ONE.prototype.instance = "ONE";
Sanitize.ONE = new Fay$$$(function(){
  return new Sanitize._ONE();
});
Sanitize._KEEP = function KEEP(){
};
Sanitize._KEEP.prototype.instance = "KEEP";
Sanitize.KEEP = new Fay$$$(function(){
  return new Sanitize._KEEP();
});
Sanitize._INDENT = function INDENT(){
};
Sanitize._INDENT.prototype.instance = "INDENT";
Sanitize.INDENT = new Fay$$$(function(){
  return new Sanitize._INDENT();
});
Sanitize._DEDENT = function DEDENT(){
};
Sanitize._DEDENT.prototype.instance = "DEDENT";
Sanitize.DEDENT = new Fay$$$(function(){
  return new Sanitize._DEDENT();
});
Sanitize._LINE = function LINE(slot1){
  this.slot1 = slot1;
};
Sanitize._LINE.prototype.instance = "LINE";
Sanitize.LINE = function(slot1){
  return new Fay$$$(function(){
    return new Sanitize._LINE(slot1);
  });
};
Sanitize.trimEnd = new Fay$$$(function(){
  return new Fay$$$(function(){
    var isSpace = function($p1){
      return new Fay$$$(function(){
        var c = $p1;
        return (function($tmp1){
          if (Fay$$_($tmp1) === "\t") {
            return true;
          }
          if (Fay$$_($tmp1) === " ") {
            return true;
          }
          return false;
        })(c);
      });
    };
    return Fay$$_(Fay$$_(Prelude.$46$)(Prelude.reverse))(Fay$$_(Fay$$_(Prelude.$46$)(Fay$$_(Prelude.dropWhile)(isSpace)))(Prelude.reverse));
  });
});
Sanitize.tolex = new Fay$$$(function(){
  return new Fay$$$(function(){
    var lexLine = function($p1){
      return function($p2){
        return new Fay$$$(function(){
          if (Fay$$listLen(Fay$$_($p2),2)) {
            var n = Fay$$index(0,Fay$$_($p2));
            var l = Fay$$index(1,Fay$$_($p2));
            if (Fay$$listLen(Fay$$_($p1),2)) {
              if (Fay$$_(Fay$$index(0,Fay$$_($p1))) === null) {
                var acc = Fay$$index(1,Fay$$_($p1));
                return Fay$$list([Fay$$list([n]),Fay$$_(Fay$$_(Prelude.$43$$43$)(acc))(Fay$$list([Fay$$_(Sanitize.LINE)(l)]))]);
              }
            }
            var n = Fay$$index(0,Fay$$_($p2));
            var l = Fay$$index(1,Fay$$_($p2));
            if (Fay$$listLen(Fay$$_($p1),2)) {
              var $tmp1 = Fay$$_(Fay$$index(0,Fay$$_($p1)));
              if ($tmp1 instanceof Fay$$Cons) {
                var d = $tmp1.car;
                var depths = $tmp1.cdr;
                var acc = Fay$$index(1,Fay$$_($p1));
                return (function($tmp1){
                  if (Fay$$_($tmp1) instanceof Prelude._GT) {
                    return Fay$$list([Fay$$_(Fay$$_(Fay$$cons)(n))(Fay$$_(Fay$$_(Fay$$cons)(d))(depths)),Fay$$_(Fay$$_(Prelude.$43$$43$)(acc))(Fay$$list([Sanitize.INDENT,Fay$$_(Sanitize.LINE)(l)]))]);
                  }
                  if (Fay$$_($tmp1) instanceof Prelude._LT) {
                    return Fay$$_(Fay$$_(lexLine)(Fay$$list([depths,Fay$$_(Fay$$_(Prelude.$43$$43$)(acc))(Fay$$list([Sanitize.DEDENT]))])))(Fay$$list([n,l]));
                  }
                  if (Fay$$_($tmp1) instanceof Prelude._EQ) {
                    return Fay$$list([Fay$$_(Fay$$_(Fay$$cons)(d))(depths),Fay$$_(Fay$$_(Prelude.$43$$43$)(acc))(Fay$$list([Fay$$_(Sanitize.LINE)(l)]))]);
                  }
                  return (function(){ throw (["unhandled case",$tmp1]); })();
                })(Fay$$_(Fay$$_(Prelude.compare)(n))(d));
              }
            }
          }
          throw ["unhandled case in lexLine",[$p1,$p2]];
        });
      };
    };
    return Fay$$_(Fay$$_(Prelude.$46$)(Prelude.snd))(Fay$$_(Fay$$_(Prelude.$46$)(Fay$$_(Fay$$_(Prelude.foldl)(lexLine))(Fay$$list([Fay$$list([0]),null]))))(Fay$$_(Fay$$_(Prelude.$46$)(Fay$$_(Prelude.map)(Sanitize.unSpace)))(Prelude.lines)));
  });
});
Sanitize.unSpace = function($p1){
  return new Fay$$$(function(){
    var l = $p1;
    return (function(){
      var cs = function($p1){
        return function($p2){
          return new Fay$$$(function(){
            var $tmp1 = Fay$$_($p2);
            if ($tmp1 instanceof Fay$$Cons) {
              if (Fay$$_($tmp1.car) === " ") {
                var s = $tmp1.cdr;
                var n = $p1;
                return Fay$$_(Fay$$_(cs)(Fay$$_(Fay$$_(Fay$$add)(1))(n)))(s);
              }
            }
            var $tmp1 = Fay$$_($p2);
            if ($tmp1 instanceof Fay$$Cons) {
              if (Fay$$_($tmp1.car) === "\t") {
                var s = $tmp1.cdr;
                var n = $p1;
                return Fay$$_(Fay$$_(cs)(Fay$$_(Fay$$_(Prelude.$36$)(tabw))(Fay$$_(Fay$$_(Fay$$add)(8))(n))))(s);
              }
            }
            var s = $p2;
            var n = $p1;
            return Fay$$list([n,Fay$$_(Sanitize.trimEnd)(s)]);
          });
        };
      };
      var tabw = function($p1){
        return new Fay$$$(function(){
          var n = $p1;
          return Fay$$_(Fay$$_(Fay$$mult)(8))(Fay$$_(Fay$$_(Prelude.div)(n))(8));
        });
      };
      return Fay$$_(Fay$$_(cs)(0))(l);
    })();
  });
};
Sanitize.prettyBlanks = function($p1){
  return new Fay$$$(function(){
    var ll = $p1;
    return (function(){
      var r = function($p1){
        return function($p2){
          return new Fay$$$(function(){
            var l = $p2;
            if (Fay$$_($p2) instanceof Sanitize._INDENT) {
              if (Fay$$listLen(Fay$$_($p1),2)) {
                var n = Fay$$index(0,Fay$$_($p1));
                var a = Fay$$index(1,Fay$$_($p1));
                return Fay$$list([Fay$$_(Fay$$_(Fay$$add)(n))(1),Fay$$_(Fay$$_(Fay$$cons)(l))(a)]);
              }
            }
            var l = $p2;
            if (Fay$$_($p2) instanceof Sanitize._DEDENT) {
              if (Fay$$listLen(Fay$$_($p1),2)) {
                if (Fay$$_(Fay$$index(0,Fay$$_($p1))) === 1) {
                  var a = Fay$$index(1,Fay$$_($p1));
                  return Fay$$list([0,Fay$$_(Fay$$_(Fay$$cons)(l))(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Sanitize.LINE)(Fay$$list(""))))(a))]);
                }
              }
            }
            var l = $p2;
            if (Fay$$_($p2) instanceof Sanitize._DEDENT) {
              if (Fay$$listLen(Fay$$_($p1),2)) {
                var n = Fay$$index(0,Fay$$_($p1));
                var a = Fay$$index(1,Fay$$_($p1));
                return Fay$$list([Fay$$_(Fay$$_(Fay$$sub)(n))(1),Fay$$_(Fay$$_(Fay$$cons)(l))(a)]);
              }
            }
            var l = $p2;
            if (Fay$$listLen(Fay$$_($p1),2)) {
              var n = Fay$$index(0,Fay$$_($p1));
              var a = Fay$$index(1,Fay$$_($p1));
              return Fay$$list([n,Fay$$_(Fay$$_(Fay$$cons)(l))(a)]);
            }
            throw ["unhandled case in r",[$p1,$p2]];
          });
        };
      };
      return Fay$$_(Fay$$_(Prelude.$36$)(Prelude.reverse))(Fay$$_(Fay$$_(Prelude.$36$)(Prelude.snd))(Fay$$_(Fay$$_(Fay$$_(Prelude.foldl)(r))(Fay$$list([0,null])))(ll)));
    })();
  });
};
Sanitize.vblanks = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var ll = $p2;
      if (Fay$$_($p1) instanceof Sanitize._NONE) {
        return (function(){
          var p = function($p1){
            return new Fay$$$(function(){
              var x = $p1;
              return (function($tmp1){
                if (Fay$$_($tmp1) instanceof Sanitize._LINE) {
                  if (Fay$$equal(Fay$$_($tmp1).slot1,Fay$$list(""))) {
                    return false;
                  }
                }
                return true;
              })(x);
            });
          };
          return Fay$$_(Fay$$_(Prelude.filter)(p))(ll);
        })();
      }
      if (Fay$$_($p2) === null) {
        if (Fay$$_($p1) instanceof Sanitize._ONE) {
          return null;
        }
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        if (Fay$$_($tmp1.car) instanceof Sanitize._LINE) {
          if (Fay$$equal(Fay$$_($tmp1.car).slot1,Fay$$list(""))) {
            var $tmp2 = Fay$$_($tmp1.cdr);
            if ($tmp2 instanceof Fay$$Cons) {
              if (Fay$$_($tmp2.car) instanceof Sanitize._LINE) {
                if (Fay$$equal(Fay$$_($tmp2.car).slot1,Fay$$list(""))) {
                  var ll = $tmp2.cdr;
                  if (Fay$$_($p1) instanceof Sanitize._ONE) {
                    return Fay$$_(Fay$$_(Sanitize.vblanks)(Sanitize.ONE))(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Sanitize.LINE)(Fay$$list(""))))(ll));
                  }
                }
              }
            }
          }
        }
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        var l = $tmp1.car;
        var ll = $tmp1.cdr;
        if (Fay$$_($p1) instanceof Sanitize._ONE) {
          return Fay$$_(Fay$$_(Fay$$cons)(l))(Fay$$_(Fay$$_(Sanitize.vblanks)(Sanitize.ONE))(ll));
        }
      }
      var ll = $p2;
      if (Fay$$_($p1) instanceof Sanitize._KEEP) {
        return ll;
      }
      var ll = $p2;
      if (Fay$$_($p1) instanceof Sanitize._AUTO) {
        return Fay$$_(Fay$$_(Prelude.$36$)(Sanitize.prettyBlanks))(Fay$$_(Fay$$_(Sanitize.vblanks)(Sanitize.NONE))(ll));
      }
      throw ["unhandled case in vblanks",[$p1,$p2]];
    });
  };
};
Sanitize.unlex = new Fay$$$(function(){
  return new Fay$$$(function(){
    var r = function($p1){
      return function($p2){
        return new Fay$$$(function(){
          if (Fay$$_($p2) instanceof Sanitize._INDENT) {
            if (Fay$$listLen(Fay$$_($p1),2)) {
              var i = Fay$$index(0,Fay$$_($p1));
              var acc = Fay$$index(1,Fay$$_($p1));
              return Fay$$list([Fay$$_(Fay$$_(Fay$$add)(i))(1),acc]);
            }
          }
          if (Fay$$_($p2) instanceof Sanitize._DEDENT) {
            if (Fay$$listLen(Fay$$_($p1),2)) {
              var i = Fay$$index(0,Fay$$_($p1));
              var acc = Fay$$index(1,Fay$$_($p1));
              return Fay$$list([Fay$$_(Fay$$_(Fay$$sub)(i))(1),acc]);
            }
          }
          if (Fay$$_($p2) instanceof Sanitize._LINE) {
            if (Fay$$equal(Fay$$_($p2).slot1,Fay$$list(""))) {
              if (Fay$$listLen(Fay$$_($p1),2)) {
                var i = Fay$$index(0,Fay$$_($p1));
                var acc = Fay$$index(1,Fay$$_($p1));
                return Fay$$list([i,Fay$$_(Fay$$_(Fay$$cons)(Fay$$list("")))(acc)]);
              }
            }
            var s = Fay$$_($p2).slot1;
            if (Fay$$listLen(Fay$$_($p1),2)) {
              var i = Fay$$index(0,Fay$$_($p1));
              var acc = Fay$$index(1,Fay$$_($p1));
              return Fay$$list([i,Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(Fay$$_(times)(i))("\t")))(s)))(acc)]);
            }
          }
          throw ["unhandled case in r",[$p1,$p2]];
        });
      };
    };
    var times = function($p1){
      return function($p2){
        return new Fay$$$(function(){
          var e = $p2;
          var i = $p1;
          return Fay$$_(Fay$$_(Prelude.take)(i))(Fay$$_(Prelude.repeat)(e));
        });
      };
    };
    return Fay$$_(Fay$$_(Prelude.$46$)(Prelude.unlines))(Fay$$_(Fay$$_(Prelude.$46$)(Prelude.reverse))(Fay$$_(Fay$$_(Prelude.$46$)(Prelude.snd))(Fay$$_(Fay$$_(Prelude.foldl)(r))(Fay$$list([0,null])))));
  });
});
Fay$$objConcat(Fay$$fayToJsHash,{"NONE": function(type,argTypes,_obj){
  var obj_ = {"instance": "NONE"};
  return obj_;
},"AUTO": function(type,argTypes,_obj){
  var obj_ = {"instance": "AUTO"};
  return obj_;
},"ONE": function(type,argTypes,_obj){
  var obj_ = {"instance": "ONE"};
  return obj_;
},"KEEP": function(type,argTypes,_obj){
  var obj_ = {"instance": "KEEP"};
  return obj_;
},"INDENT": function(type,argTypes,_obj){
  var obj_ = {"instance": "INDENT"};
  return obj_;
},"DEDENT": function(type,argTypes,_obj){
  var obj_ = {"instance": "DEDENT"};
  return obj_;
},"LINE": function(type,argTypes,_obj){
  var obj_ = {"instance": "LINE"};
  var obj_slot1 = Fay$$fayToJs_string(_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"NONE": function(type,argTypes,obj){
  return new Sanitize._NONE();
},"AUTO": function(type,argTypes,obj){
  return new Sanitize._AUTO();
},"ONE": function(type,argTypes,obj){
  return new Sanitize._ONE();
},"KEEP": function(type,argTypes,obj){
  return new Sanitize._KEEP();
},"INDENT": function(type,argTypes,obj){
  return new Sanitize._INDENT();
},"DEDENT": function(type,argTypes,obj){
  return new Sanitize._DEDENT();
},"LINE": function(type,argTypes,obj){
  return new Sanitize._LINE(Fay$$jsToFay_string(obj["slot1"]));
}});
var UI = {};
UI.gid = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["nullable",[["user","JSDOM",[]]]],(document.getElementById(Fay$$fayToJs_string($p1)))));
  });
};
UI.mknode = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["user","JSDOM",[]],(document.createElement(Fay$$fayToJs_string($p1)))));
  });
};
UI.setText = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return new Fay$$Monad(Fay$$jsToFay(["unknown"],((Fay$$fayToJs(["user","JSDOM",[]],$p1)).innerText = Fay$$fayToJs_string($p2))));
    });
  };
};
UI.setAttr = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        return new Fay$$Monad(Fay$$jsToFay(["unknown"],((Fay$$fayToJs(["user","JSDOM",[]],$p1)).setAttribute(Fay$$fayToJs_string($p2),Fay$$fayToJs_string($p3)))));
      });
    };
  };
};
UI.getChilds = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["list",[["user","JSDOM",[]]]],((Fay$$fayToJs(["user","JSDOM",[]],$p1)).children)));
  });
};
UI.removeChild = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return new Fay$$Monad(Fay$$jsToFay(["unknown"],((Fay$$fayToJs(["user","JSDOM",[]],$p1)).removeChild(Fay$$fayToJs(["user","JSDOM",[]],$p2)))));
    });
  };
};
UI.prompt = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return new Fay$$Monad(Fay$$jsToFay(["nullable",[["string"]]],(prompt(Fay$$fayToJs_string($p1),Fay$$fayToJs_string($p2)))));
    });
  };
};
UI.onClick = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return new Fay$$Monad(Fay$$jsToFay(["unknown"],((Fay$$fayToJs(["user","JSDOM",[]],$p1)).onclick = (Fay$$fayToJs(["action",[["unknown"]]],$p2)))));
    });
  };
};
UI.onKeyDown$39$ = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["unknown"],document.onkeydown = (Fay$$fayToJs(["function",[["user","JS",[]],["action",[["unknown"]]]]],$p1))));
  });
};
UI.onKeyPress$39$ = function($p1){
  return new Fay$$$(function(){
    return new Fay$$Monad(Fay$$jsToFay(["unknown"],document.onkeypress = (Fay$$fayToJs(["function",[["user","JS",[]],["action",[["unknown"]]]]],$p1))));
  });
};
UI.keyCode = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_int(((Fay$$fayToJs(["user","JS",[]],$p1)).keyCode));
  });
};
UI.charCodeToString = function($p1){
  return new Fay$$$(function(){
    return Fay$$jsToFay_string((String.fromCharCode(Fay$$fayToJs_int($p1))));
  });
};
UI.onKeyDown = function($p1){
  return new Fay$$$(function(){
    var p = $p1;
    return Fay$$_(UI.onKeyDown$39$)(Fay$$_(Fay$$_(Prelude.$46$)(p))(UI.keyCode));
  });
};
UI.onKeyPress = function($p1){
  return new Fay$$$(function(){
    var p = $p1;
    return Fay$$_(UI.onKeyPress$39$)(Fay$$_(Fay$$_(Prelude.$46$)(p))(Fay$$_(Fay$$_(Prelude.$46$)(UI.charCodeToString))(UI.keyCode)));
  });
};
UI.appendChild = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      return new Fay$$Monad(Fay$$jsToFay(["unknown"],((Fay$$fayToJs(["user","JSDOM",[]],$p1)).appendChild(Fay$$fayToJs(["user","JSDOM",[]],$p2)))));
    });
  };
};
UI._Node = function Node(tag,attrs,text,click,childs){
  this.tag = tag;
  this.attrs = attrs;
  this.text = text;
  this.click = click;
  this.childs = childs;
};
UI._Node.prototype.instance = "Node";
UI.Node = function(tag){
  return function(attrs){
    return function(text){
      return function(click){
        return function(childs){
          return new Fay$$$(function(){
            return new UI._Node(tag,attrs,text,click,childs);
          });
        };
      };
    };
  };
};
UI.tag = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).tag;
  });
};
UI.attrs = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).attrs;
  });
};
UI.text = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).text;
  });
};
UI.click = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).click;
  });
};
UI.childs = function(x){
  return new Fay$$$(function(){
    return Fay$$_(x).childs;
  });
};
UI.dom = function($p1){
  return new Fay$$$(function(){
    var s = $p1;
    return (function(){
      var Node = new UI._Node();
      Node.tag = s;
      Node.attrs = null;
      Node.text = Prelude.Nothing;
      Node.click = Prelude.Nothing;
      Node.childs = null;
      return Node;
    })();
  });
};
UI.dP = new Fay$$$(function(){
  return Fay$$_(UI.dom)(Fay$$list("p"));
});
UI.dSPAN = new Fay$$$(function(){
  return Fay$$_(UI.dom)(Fay$$list("span"));
});
UI.dUL = new Fay$$$(function(){
  return Fay$$_(UI.dom)(Fay$$list("ul"));
});
UI.dDIV = new Fay$$$(function(){
  return Fay$$_(UI.dom)(Fay$$list("div"));
});
UI.dLI = new Fay$$$(function(){
  return Fay$$_(UI.dom)(Fay$$list("li"));
});
UI.dPRE = new Fay$$$(function(){
  return Fay$$_(UI.dom)(Fay$$list("pre"));
});
UI.dText = function($p1){
  return new Fay$$$(function(){
    var s = $p1;
    return (function(){
      var $36$_record_to_update = Object.create(Fay$$_(UI.dSPAN));
      $36$_record_to_update.text = Fay$$_(Prelude.Just)(s);
      return $36$_record_to_update;
    })();
  });
};
UI._Vars = function Vars(slot1){
  this.slot1 = slot1;
};
UI._Vars.prototype.instance = "Vars";
UI.Vars = function(slot1){
  return new Fay$$$(function(){
    return new UI._Vars(slot1);
  });
};
UI._ByText = function ByText(){
};
UI._ByText.prototype.instance = "ByText";
UI.ByText = new Fay$$$(function(){
  return new UI._ByText();
});
UI._ByList = function ByList(){
};
UI._ByList.prototype.instance = "ByList";
UI.ByList = new Fay$$$(function(){
  return new UI._ByList();
});
UI.render = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof UI._ByText) {
      return UI.olTextDom;
    }
    if (Fay$$_($p1) instanceof UI._ByList) {
      return UI.olListDom;
    }
    throw ["unhandled case in render",[$p1]];
  });
};
UI.otherMeth = function($p1){
  return new Fay$$$(function(){
    if (Fay$$_($p1) instanceof UI._ByText) {
      return UI.ByList;
    }
    if (Fay$$_($p1) instanceof UI._ByList) {
      return UI.ByText;
    }
    throw ["unhandled case in otherMeth",[$p1]];
  });
};
UI.olTextDom = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var tree = $p3;
        var selection = $p2;
        var vars = $p1;
        return (function(){
          var l = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                var txt = $p2;
                var a = $p1;
                return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(fmt)(a)))((function(){
                  var $36$_record_to_update = Object.create(Fay$$_(UI.dSPAN));
                  $36$_record_to_update.attrs = Fay$$list([Fay$$_(cls)(a)]);
                  $36$_record_to_update.text = Fay$$_(Prelude.Just)(Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(Outline.unols)(txt)))(Fay$$list("\n")));
                  $36$_record_to_update.click = Fay$$_(Prelude.Just)(Fay$$_(Fay$$_(UI.select)(vars))(a));
                  return $36$_record_to_update;
                })());
              });
            };
          };
          var cls = function($p1){
            return new Fay$$$(function(){
              var a = $p1;
              return Fay$$list([Fay$$list("class"),Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(a))(selection)) ? Fay$$list("selected") : Fay$$list("unselected")]);
            });
          };
          var fmt = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                var t = $p2;
                if (Fay$$_($p1) instanceof Outline._Addr) {
                  var a = Fay$$_($p1).slot1;
                  return (function(){
                    var $36$_record_to_update = Object.create(Fay$$_(UI.dDIV));
                    $36$_record_to_update.childs = Fay$$list([Fay$$_(Fay$$_(Prelude.$36$)(UI.dText))(Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Prelude.take)(Fay$$_(Fay$$_(Fay$$mult)(2))(Fay$$_(Prelude.length)(a)))))(Fay$$_(Prelude.repeat)(" "))),t]);
                    return $36$_record_to_update;
                  })();
                }
                throw ["unhandled case in fmt",[$p1,$p2]];
              });
            };
          };
          var r = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                if (Fay$$_($p2) instanceof Outline._OL) {
                  var txt = Fay$$_($p2).slot1;
                  var cs = Fay$$_($p2).slot2;
                  var a = $p1;
                  return Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(l)(a))(txt)))(Fay$$_(Prelude.concat)(Fay$$_(Fay$$_(Fay$$_(Outline.addrmap)(a))(r))(cs)));
                }
                throw ["unhandled case in r",[$p1,$p2]];
              });
            };
          };
          var top = function($p1){
            return new Fay$$$(function(){
              if (Fay$$_($p1) instanceof Outline._OL) {
                var txt = Fay$$_($p1).slot1;
                var cs = Fay$$_($p1).slot2;
                return (function(){
                  var $36$_record_to_update = Object.create(Fay$$_(UI.dPRE));
                  $36$_record_to_update.childs = Fay$$_(Fay$$_(Prelude.$43$$43$)(Fay$$_(Fay$$_(Fay$$cons)(Fay$$_(Fay$$_(l)(Fay$$_(Outline.Addr)(null)))(txt)))(Fay$$_(Prelude.concat)(Fay$$_(Fay$$_(Fay$$_(Outline.addrmap)(Fay$$_(Outline.Addr)(null)))(r))(cs)))))(eol);
                  return $36$_record_to_update;
                })();
              }
              throw ["unhandled case in top",[$p1]];
            });
          };
          var eol = new Fay$$$(function(){
            return Fay$$list([Fay$$_(UI.dText)(Fay$$list("\n"))]);
          });
          return Fay$$_(top)(tree);
        })();
      });
    };
  };
};
UI.olListDom = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var tree = $p3;
        var selection = $p2;
        var vars = $p1;
        return (function(){
          var l = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                var txt = $p2;
                var a = $p1;
                return (function(){
                  var $36$_record_to_update = Object.create(Fay$$_(UI.dSPAN));
                  $36$_record_to_update.attrs = Fay$$list([Fay$$_(cls)(a)]);
                  $36$_record_to_update.text = Fay$$_(Prelude.Just)(Fay$$_(Outline.unols)(txt));
                  $36$_record_to_update.click = Fay$$_(Prelude.Just)(Fay$$_(Fay$$_(UI.select)(vars))(a));
                  return $36$_record_to_update;
                })();
              });
            };
          };
          var cls = function($p1){
            return new Fay$$$(function(){
              var a = $p1;
              return Fay$$list([Fay$$list("class"),Fay$$_(Fay$$_(Fay$$_(Fay$$eq)(a))(selection)) ? Fay$$list("selected") : Fay$$list("unselected")]);
            });
          };
          var r = function($p1){
            return function($p2){
              return new Fay$$$(function(){
                if (Fay$$_($p2) instanceof Outline._OL) {
                  var txt = Fay$$_($p2).slot1;
                  if (Fay$$_(Fay$$_($p2).slot2) === null) {
                    var a = $p1;
                    return Fay$$list([(function(){
                      var $36$_record_to_update = Object.create(Fay$$_(UI.dLI));
                      $36$_record_to_update.childs = Fay$$list([Fay$$_(Fay$$_(l)(a))(txt)]);
                      return $36$_record_to_update;
                    })()]);
                  }
                  var txt = Fay$$_($p2).slot1;
                  var cs = Fay$$_($p2).slot2;
                  var a = $p1;
                  return Fay$$list([(function(){
                    var $36$_record_to_update = Object.create(Fay$$_(UI.dLI));
                    $36$_record_to_update.childs = Fay$$list([Fay$$_(Fay$$_(l)(a))(txt)]);
                    return $36$_record_to_update;
                  })(),(function(){
                    var $36$_record_to_update = Object.create(Fay$$_(UI.dUL));
                    $36$_record_to_update.childs = Fay$$_(Fay$$_(Prelude.$36$)(Prelude.concat))(Fay$$_(Fay$$_(Fay$$_(Outline.addrmap)(a))(r))(cs));
                    return $36$_record_to_update;
                  })()]);
                }
                throw ["unhandled case in r",[$p1,$p2]];
              });
            };
          };
          var top = function($p1){
            return new Fay$$$(function(){
              if (Fay$$_($p1) instanceof Outline._OL) {
                var txt = Fay$$_($p1).slot1;
                if (Fay$$_(Fay$$_($p1).slot2) === null) {
                  return (function(){
                    var $36$_record_to_update = Object.create(Fay$$_(UI.dP));
                    $36$_record_to_update.childs = Fay$$list([Fay$$_(Fay$$_(l)(Fay$$_(Outline.Addr)(null)))(txt)]);
                    return $36$_record_to_update;
                  })();
                }
                var txt = Fay$$_($p1).slot1;
                var cs = Fay$$_($p1).slot2;
                return (function(){
                  var $36$_record_to_update = Object.create(Fay$$_(UI.dP));
                  $36$_record_to_update.childs = Fay$$list([Fay$$_(Fay$$_(l)(Fay$$_(Outline.Addr)(null)))(txt),(function(){
                    var $36$_record_to_update = Object.create(Fay$$_(UI.dUL));
                    $36$_record_to_update.childs = Fay$$_(Fay$$_(Prelude.$36$)(Prelude.concat))(Fay$$_(Fay$$_(Fay$$_(Outline.addrmap)(Fay$$_(Outline.Addr)(null)))(r))(cs));
                    return $36$_record_to_update;
                  })()]);
                  return $36$_record_to_update;
                })();
              }
              throw ["unhandled case in top",[$p1]];
            });
          };
          return Fay$$_(top)(tree);
        })();
      });
    };
  };
};
UI.setAttrs = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      if (Fay$$_($p2) === null) {
        return Fay$$_(Fay$$$_return)(Fay$$unit);
      }
      var $tmp1 = Fay$$_($p2);
      if ($tmp1 instanceof Fay$$Cons) {
        if (Fay$$listLen(Fay$$_($tmp1.car),2)) {
          var k = Fay$$index(0,Fay$$_($tmp1.car));
          var v = Fay$$index(1,Fay$$_($tmp1.car));
          var as = $tmp1.cdr;
          var n = $p1;
          return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(Fay$$_(Fay$$_(UI.setAttr)(n))(k))(v)))(Fay$$_(Fay$$_(UI.setAttrs)(n))(as));
        }
      }
      throw ["unhandled case in setAttrs",[$p1,$p2]];
    });
  };
};
UI.getOutlineNode = new Fay$$$(function(){
  return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(UI.gid)(Fay$$list("outline"))))(function($p1){
    var ol = $p1;
    return (function($tmp1){
      if (Fay$$_($tmp1) instanceof Fay.FFI._Null) {
        return Fay$$_(Prelude.error)(Fay$$list("There has to be a node with id=“outline” in the document."));
      }
      if (Fay$$_($tmp1) instanceof Fay.FFI._Nullable) {
        var node = Fay$$_($tmp1).slot1;
        return Fay$$_(Fay$$$_return)(node);
      }
      return (function(){ throw (["unhandled case",$tmp1]); })();
    })(ol);
  });
});
UI.clearPage = new Fay$$$(function(){
  return Fay$$_(Fay$$_(Fay$$bind)(UI.getOutlineNode))(function($p1){
    var o = $p1;
    return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(UI.getChilds)(o)))(Fay$$_(Util.iter)(Fay$$_(UI.removeChild)(o)));
  });
});
UI.writePage = function($p1){
  return new Fay$$$(function(){
    var d = $p1;
    return Fay$$_(Fay$$_(Fay$$bind)(UI.getOutlineNode))(function($p1){
      var o = $p1;
      return Fay$$_(Fay$$_(UI.appendChild)(o))(d);
    });
  });
};
UI.setPage = function($p1){
  return new Fay$$$(function(){
    var x = $p1;
    return Fay$$_(Fay$$_(Fay$$then)(UI.clearPage))(Fay$$_(UI.writePage)(x));
  });
};
UI.gendom = function($p1){
  return new Fay$$$(function(){
    var d = $p1;
    return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(UI.mknode)(Fay$$_(UI.tag)(d))))(function($p1){
      var n = $p1;
      return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(Fay$$_(UI.setAttrs)(n))(Fay$$_(UI.attrs)(d))))(Fay$$_(Fay$$_(Fay$$then)((function($tmp1){
        if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
          return Fay$$_(Fay$$$_return)(Fay$$unit);
        }
        if (Fay$$_($tmp1) instanceof Prelude._Just) {
          var s = Fay$$_($tmp1).slot1;
          return Fay$$_(Fay$$_(UI.setText)(n))(s);
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(Fay$$_(UI.text)(d))))(Fay$$_(Fay$$_(Fay$$then)(Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(Fay$$_(Util.mymapM)(UI.gendom))(Fay$$_(UI.childs)(d))))(Fay$$_(Util.iter)(Fay$$_(UI.appendChild)(n)))))(Fay$$_(Fay$$_(Fay$$then)((function($tmp1){
        if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
          return Fay$$_(Fay$$$_return)(Fay$$unit);
        }
        if (Fay$$_($tmp1) instanceof Prelude._Just) {
          var c = Fay$$_($tmp1).slot1;
          return Fay$$_(Fay$$_(UI.onClick)(n))(Fay$$_(c)(n));
        }
        return (function(){ throw (["unhandled case",$tmp1]); })();
      })(Fay$$_(UI.click)(d))))(Fay$$_(Fay$$$_return)(n)))));
    });
  });
};
UI.prompt$39$ = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var default$39$ = $p2;
      var q = $p1;
      return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(Fay$$_(UI.prompt)(q))(default$39$)))(function($p1){
        var x = $p1;
        return (function($tmp1){
          if (Fay$$_($tmp1) instanceof Fay.FFI._Null) {
            return Fay$$_(Fay$$$_return)(default$39$);
          }
          if (Fay$$_($tmp1) instanceof Fay.FFI._Nullable) {
            var t = Fay$$_($tmp1).slot1;
            return Fay$$_(Fay$$$_return)(t);
          }
          return (function(){ throw (["unhandled case",$tmp1]); })();
        })(x);
      });
    });
  };
};
UI.select = function($p1){
  return function($p2){
    return function($p3){
      return new Fay$$$(function(){
        var a = $p2;
        var vars = $p1;
        return (function(){
          var f = function($p1){
            return new Fay$$$(function(){
              if (Fay$$_($p1) instanceof UI._Vars) {
                if (Fay$$listLen(Fay$$_(Fay$$_($p1).slot1),2)) {
                  var e = Fay$$index(0,Fay$$_(Fay$$_($p1).slot1));
                  var r = Fay$$index(1,Fay$$_(Fay$$_($p1).slot1));
                  return Fay$$_(UI.Vars)(Fay$$list([Fay$$_(Fay$$_(Editor.apply)(Fay$$_(Editor.Select)(a)))(e),r]));
                }
              }
              throw ["unhandled case in f",[$p1]];
            });
          };
          return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(Fay$$_(FayRef.modifyFayRef)(vars))(f)))(Fay$$_(UI.buildit)(vars));
        })();
      });
    };
  };
};
UI.editKey = function($p1){
  return function($p2){
    return new Fay$$$(function(){
      var k = $p2;
      var t = $p1;
      return (function($tmp1){
        if (Fay$$equal($tmp1,Fay$$list("h"))) {
          return Fay$$_(Fay$$$_return)(Editor.SelLeft);
        }
        if (Fay$$equal($tmp1,Fay$$list("l"))) {
          return Fay$$_(Fay$$$_return)(Editor.SelRight);
        }
        if (Fay$$equal($tmp1,Fay$$list("k"))) {
          return Fay$$_(Fay$$$_return)(Editor.SelUp);
        }
        if (Fay$$equal($tmp1,Fay$$list("j"))) {
          return Fay$$_(Fay$$$_return)(Editor.SelDown);
        }
        if (Fay$$equal($tmp1,Fay$$list("d"))) {
          return Fay$$_(Fay$$$_return)(Editor.Delete);
        }
        if (Fay$$equal($tmp1,Fay$$list("u"))) {
          return Fay$$_(Fay$$$_return)(Editor.Undo);
        }
        if (Fay$$equal($tmp1,Fay$$list("i"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Fay$$_(Fay$$_(Prelude.$36$)(Editor.InsBefore))(Fay$$_(Outline.ols)(Fay$$list(""))));
        }
        if (Fay$$equal($tmp1,Fay$$list("a"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Fay$$_(Fay$$_(Prelude.$36$)(Editor.InsAfter))(Fay$$_(Outline.ols)(Fay$$list(""))));
        }
        if (Fay$$equal($tmp1,Fay$$list("o"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Fay$$_(Fay$$_(Prelude.$36$)(Editor.InsBelow))(Fay$$_(Outline.ols)(Fay$$list(""))));
        }
        if (Fay$$equal($tmp1,Fay$$list("O"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Fay$$_(Fay$$_(Prelude.$36$)(Editor.InsAbove))(Fay$$_(Outline.ols)(Fay$$list(""))));
        }
        if (Fay$$equal($tmp1,Fay$$list("y"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Editor.Copy);
        }
        if (Fay$$equal($tmp1,Fay$$list("P"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Editor.PasteBefore);
        }
        if (Fay$$equal($tmp1,Fay$$list("p"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Editor.PasteAfter);
        }
        if (Fay$$equal($tmp1,Fay$$list("x"))) {
          return Fay$$_(Fay$$_(Prelude.$36$)(Fay$$$_return))(Editor.Cut);
        }
        if (Fay$$equal($tmp1,Fay$$list("r"))) {
          return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(Fay$$_(UI.prompt$39$)(Fay$$list("Replace Text")))(t)))(Fay$$_(Fay$$_(Prelude.$46$)(Fay$$$_return))(Fay$$_(Fay$$_(Prelude.$46$)(Editor.ReplaceTxt))(Outline.ols)));
        }
        if (Fay$$equal($tmp1,Fay$$list("\r"))) {
          return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(Fay$$_(UI.prompt$39$)(Fay$$list("Replace Text")))(t)))(Fay$$_(Fay$$_(Prelude.$46$)(Fay$$$_return))(Fay$$_(Fay$$_(Prelude.$46$)(Editor.ReplaceTxt))(Outline.ols)));
        }
        return Fay$$_(Fay$$$_return)(Editor.Nada);
      })(k);
    });
  };
};
UI.setupKeys = function($p1){
  return new Fay$$$(function(){
    var vars = $p1;
    return (function(){
      var kpress = function($p1){
        return new Fay$$$(function(){
          if (Fay$$equal($p1,Fay$$list("!"))) {
            return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(Fay$$_(FayRef.modifyFayRef)(vars))(function($p1){
              if (Fay$$_($p1) instanceof UI._Vars) {
                if (Fay$$listLen(Fay$$_(Fay$$_($p1).slot1),2)) {
                  var e = Fay$$index(0,Fay$$_(Fay$$_($p1).slot1));
                  var r = Fay$$index(1,Fay$$_(Fay$$_($p1).slot1));
                  return Fay$$_(UI.Vars)(Fay$$list([e,Fay$$_(UI.otherMeth)(r)]));
                }
              }
              throw ["unhandled case",$p1];
            })))(Fay$$_(UI.buildit)(vars));
          }
          var k = $p1;
          return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(FayRef.readFayRef)(vars)))(function($p1){
            if (Fay$$_($p1) instanceof UI._Vars) {
              if (Fay$$listLen(Fay$$_(Fay$$_($p1).slot1),2)) {
                var s = Fay$$index(0,Fay$$_(Fay$$_($p1).slot1));
                var r = Fay$$index(1,Fay$$_(Fay$$_($p1).slot1));
                return (function($tmp1){
                  if (Fay$$_($tmp1) instanceof Prelude._Nothing) {
                    return Fay$$_(Fay$$$_return)(Fay$$unit);
                  }
                  if (Fay$$_($tmp1) instanceof Prelude._Just) {
                    var e = Fay$$_($tmp1).slot1;
                    return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(Fay$$_(UI.editKey)(e))(k)))(function($p1){
                      var op = $p1;
                      return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(Fay$$_(FayRef.writeFayRef)(vars))(Fay$$_(UI.Vars)(Fay$$list([Fay$$_(Fay$$_(Editor.apply)(op))(s),r])))))(Fay$$_(UI.buildit)(vars));
                    });
                  }
                  return (function(){ throw (["unhandled case",$tmp1]); })();
                })(Fay$$_(Fay$$_(Prelude.$36$)(Fay$$_(Util.mmap)(Outline.oltext)))(Fay$$_(Fay$$_(Outline.olget)(Fay$$_(Editor.stSel)(s)))(Fay$$_(Editor.stOL)(s))));
              }
            }
            throw ["unhandled case",$p1];
          });
        });
      };
      var kdown = function($p1){
        return new Fay$$$(function(){
          if (Fay$$_($p1) === 37) {
            return Fay$$_(kpress)(Fay$$list("h"));
          }
          if (Fay$$_($p1) === 38) {
            return Fay$$_(kpress)(Fay$$list("k"));
          }
          if (Fay$$_($p1) === 39) {
            return Fay$$_(kpress)(Fay$$list("l"));
          }
          if (Fay$$_($p1) === 40) {
            return Fay$$_(kpress)(Fay$$list("j"));
          }
          return Fay$$_(Fay$$$_return)(Fay$$unit);
        });
      };
      return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(UI.onKeyPress)(kpress)))(Fay$$_(UI.onKeyDown)(kdown));
    })();
  });
};
UI.buildit = function($p1){
  return new Fay$$$(function(){
    var vars = $p1;
    return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(FayRef.readFayRef)(vars)))(function($p1){
      if (Fay$$_($p1) instanceof UI._Vars) {
        if (Fay$$listLen(Fay$$_(Fay$$_($p1).slot1),2)) {
          var editor = Fay$$index(0,Fay$$_(Fay$$_($p1).slot1));
          var method = Fay$$index(1,Fay$$_(Fay$$_($p1).slot1));
          return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(UI.gendom)(Fay$$_(Fay$$_(Fay$$_(Fay$$_(UI.render)(method))(vars))(Fay$$_(Editor.stSel)(editor)))(Fay$$_(Editor.stOL)(editor)))))(UI.setPage);
        }
      }
      throw ["unhandled case",$p1];
    });
  });
};
UI.main = new Fay$$$(function(){
  return Fay$$_(Fay$$_(Fay$$bind)(Fay$$_(Fay$$_(Prelude.$36$)(FayRef.newFayRef))(Fay$$_(UI.Vars)(Fay$$list([Fay$$_(Fay$$_(Editor.mkeditor)(Fay$$_(Outline.Addr)(null)))(Outline.olexample),UI.ByList])))))(function($p1){
    var vars = $p1;
    return Fay$$_(Fay$$_(Fay$$then)(Fay$$_(UI.buildit)(vars)))(Fay$$_(UI.setupKeys)(vars));
  });
});
Fay$$objConcat(Fay$$fayToJsHash,{"Node": function(type,argTypes,_obj){
  var obj_ = {"instance": "Node"};
  var obj_tag = Fay$$fayToJs_string(_obj.tag);
  if (undefined !== obj_tag) {
    obj_['tag'] = obj_tag;
  }
  var obj_attrs = Fay$$fayToJs(["list",[["tuple",[["string"],["string"]]]]],_obj.attrs);
  if (undefined !== obj_attrs) {
    obj_['attrs'] = obj_attrs;
  }
  var obj_text = Fay$$fayToJs(["user","Maybe",[["string"]]],_obj.text);
  if (undefined !== obj_text) {
    obj_['text'] = obj_text;
  }
  var obj_click = Fay$$fayToJs(["user","Maybe",[["function",[["user","JSDOM",[]],["action",[argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"]]]]]]],_obj.click);
  if (undefined !== obj_click) {
    obj_['click'] = obj_click;
  }
  var obj_childs = Fay$$fayToJs(["list",[["user","DOM",[]]]],_obj.childs);
  if (undefined !== obj_childs) {
    obj_['childs'] = obj_childs;
  }
  return obj_;
},"Vars": function(type,argTypes,_obj){
  var obj_ = {"instance": "Vars"};
  var obj_slot1 = Fay$$fayToJs(["tuple",[["user","Editor",[]],["user","RenderMethod",[]]]],_obj.slot1);
  if (undefined !== obj_slot1) {
    obj_['slot1'] = obj_slot1;
  }
  return obj_;
},"ByText": function(type,argTypes,_obj){
  var obj_ = {"instance": "ByText"};
  return obj_;
},"ByList": function(type,argTypes,_obj){
  var obj_ = {"instance": "ByList"};
  return obj_;
}});
Fay$$objConcat(Fay$$jsToFayHash,{"Node": function(type,argTypes,obj){
  return new UI._Node(Fay$$jsToFay_string(obj["tag"]),Fay$$jsToFay(["list",[["tuple",[["string"],["string"]]]]],obj["attrs"]),Fay$$jsToFay(["user","Maybe",[["string"]]],obj["text"]),Fay$$jsToFay(["user","Maybe",[["function",[["user","JSDOM",[]],["action",[argTypes && (argTypes)[0] ? (argTypes)[0] : (type)[0] === "automatic" ? ["automatic"] : ["unknown"]]]]]]],obj["click"]),Fay$$jsToFay(["list",[["user","DOM",[]]]],obj["childs"]));
},"Vars": function(type,argTypes,obj){
  return new UI._Vars(Fay$$jsToFay(["tuple",[["user","Editor",[]],["user","RenderMethod",[]]]],obj["slot1"]));
},"ByText": function(type,argTypes,obj){
  return new UI._ByText();
},"ByList": function(type,argTypes,obj){
  return new UI._ByList();
}});

